From 96a91dee869f1419454a2ebbebf5a4f6b1ee9ef1 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ckanext/harvest/logic/action/update.py b/ckanext/harvest/logic/action/update.py index 3931c54..9431d44 100644 --- a/ckanext/harvest/logic/action/update.py +++ b/ckanext/harvest/logic/action/update.py @@ -211,6 +211,16 @@ 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 + context.update({'validate': False, 'ignore_auth': True}) + package_dict = logic.get_action('package_show')(context, + {'id': job_obj.source.id}) + import pdb; pdb.set_trace() + 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'})