From f9b87fff0c950fb50b7fee2acc9349e6e5dbbd84 Mon Sep 17 00:00:00 2001 From: Stefan Oderbolz Date: Tue, 17 Nov 2015 11:43:11 +0100 Subject: [PATCH] Make sure all possible status are always returned It makes it harded to parse the API response if you always have to check if 'deleted' is set and if what value it has. I think to simply return 0 for all status value is good practice. --- ckanext/harvest/logic/dictization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/harvest/logic/dictization.py b/ckanext/harvest/logic/dictization.py index 23024d7..ce88ee5 100644 --- a/ckanext/harvest/logic/dictization.py +++ b/ckanext/harvest/logic/dictization.py @@ -37,7 +37,7 @@ def harvest_job_dictize(job, context): func.count(HarvestObject.id).label('total_objects'))\ .filter_by(harvest_job_id=job.id)\ .group_by(HarvestObject.report_status).all() - out['stats'] = {} + out['stats'] = {'added': 0, 'updated': 0, 'errors': 0, 'deleted': 0} for status, count in stats: out['stats'][status] = count