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)
This commit is contained in:
amercader 2012-12-14 12:39:01 +00:00
parent c1b0415cb6
commit 6df525a377
1 changed files with 12 additions and 0 deletions

View File

@ -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'})