From 6df525a377fa07e0ec59e7625d591ac2cd6c3669 Mon Sep 17 00:00:00 2001 From: amercader Date: Fri, 14 Dec 2012 12:39:01 +0000 Subject: [PATCH] Reindex the harvest source dataset after finishing jobs This ensures that the status details shown on the harvest sources search page is up to date (as it is loaded from the indexed data_dict) --- ckanext/harvest/logic/action/update.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ckanext/harvest/logic/action/update.py b/ckanext/harvest/logic/action/update.py index 3931c54..4d66ea7 100644 --- a/ckanext/harvest/logic/action/update.py +++ b/ckanext/harvest/logic/action/update.py @@ -211,6 +211,18 @@ def harvest_jobs_run(context,data_dict): job_obj = HarvestJob.get(job['id']) job_obj.status = u'Finished' job_obj.save() + # Reindex the harvest source dataset so it has the latest + # status + if 'extras_as_string'in context: + del context['extras_as_string'] + context.update({'validate': False, 'ignore_auth': True}) + package_dict = logic.get_action('package_show')(context, + {'id': job_obj.source.id}) + + if package_dict: + from ckan.lib.search.index import PackageSearchIndex + PackageSearchIndex().index_package(package_dict) + # Check if there are pending harvest jobs jobs = harvest_job_list(context,{'source_id':source_id,'status':u'New'})