Merge pull request #263 from metaodi/add-last-job-status

Add new parameter return_last_job_status to harvest_source_list
This commit is contained in:
Adrià Mercader 2016-08-31 11:23:42 +01:00 committed by GitHub
commit 57173ff9fe
2 changed files with 9 additions and 6 deletions

View File

@ -130,7 +130,9 @@ def harvest_source_list(context, data_dict):
sources = _get_sources_for_user(context, data_dict)
return [harvest_source_dictize(source, context) for source in sources]
last_job_status = p.toolkit.asbool(data_dict.get('return_last_job_status', False))
return [harvest_source_dictize(source, context, last_job_status) for source in sources]
@side_effect_free

View File

@ -1,15 +1,12 @@
from sqlalchemy import distinct, func
from ckan.model import Package, Group
from ckan import logic
from ckanext.harvest.model import (HarvestSource, HarvestJob, HarvestObject,
HarvestGatherError, HarvestObjectError)
def harvest_source_dictize(source, context):
'''
TODO: Deprecated
'''
def harvest_source_dictize(source, context, last_job_status=False):
out = source.as_dict()
out['publisher_title'] = u''
@ -22,6 +19,10 @@ def harvest_source_dictize(source, context):
out['status'] = _get_source_status(source, context)
if last_job_status:
source_status = logic.get_action('harvest_source_show_status')(context, {'id': source.id})
out['last_job_status'] = source_status.get('last_job', {})
return out