Fix error count in job stats

We want to take into account objects with errors that where created or
updated anyway (eg bbox errors), so we bascially query for the number of
objects that have object errors.

Also add the number of gather errors to this count.
This commit is contained in:
amercader 2013-03-06 13:44:04 +00:00
parent ef2defbcf9
commit 74633d0803
1 changed files with 16 additions and 0 deletions

View File

@ -37,6 +37,22 @@ def harvest_job_dictize(job, context):
for status, count in stats: for status, count in stats:
out['stats'][status] = count out['stats'][status] = count
# We actually want to check which objects had errors, because they
# could have been added/updated anyway (eg bbox errors)
count = model.Session.query(func.distinct(HarvestObjectError.harvest_object_id)) \
.join(HarvestObject) \
.filter(HarvestObject.harvest_job_id==job.id) \
.count()
if count > 0:
out['stats']['errored'] = count
# Add gather errors to the error count
count = model.Session.query(HarvestGatherError) \
.filter(HarvestGatherError.harvest_job_id==job.id) \
.count()
if count > 0:
out['stats']['errored'] = out['stats'].get('errored', 0) + count
if context.get('return_error_summary', True): if context.get('return_error_summary', True):
q = model.Session.query(HarvestObjectError.message, \ q = model.Session.query(HarvestObjectError.message, \
func.count(HarvestObjectError.message).label('error_count')) \ func.count(HarvestObjectError.message).label('error_count')) \