Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move datasets to delete first in line #261

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ckanext/spatial/harvesters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def import_stage(self, harvest_object):
context.update({
'ignore_auth': True,
})
p.toolkit.get_action('package_delete')(context, {'id': harvest_object.package_id})
p.toolkit.get_action('package_purge')(context, {'id': harvest_object.package_id})
log.info('Deleted package {0} with guid {1}'.format(harvest_object.package_id, harvest_object.guid))

return True
Expand Down
26 changes: 13 additions & 13 deletions ckanext/spatial/harvesters/waf.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ def create_extras(url, date, status):


ids = []
for location in delete:
obj = HarvestObject(job=harvest_job,
extras=create_extras('','', 'delete'),
guid=url_to_ids[location][0],
package_id=url_to_ids[location][1],
)
model.Session.query(HarvestObject).\
filter_by(guid=url_to_ids[location][0]).\
update({'current': False}, False)

obj.save()
ids.append(obj.id)

for location in new:
guid=hashlib.md5(location.encode('utf8','ignore')).hexdigest()
obj = HarvestObject(job=harvest_job,
Expand All @@ -155,19 +168,6 @@ def create_extras(url, date, status):
obj.save()
ids.append(obj.id)

for location in delete:
obj = HarvestObject(job=harvest_job,
extras=create_extras('','', 'delete'),
guid=url_to_ids[location][0],
package_id=url_to_ids[location][1],
)
model.Session.query(HarvestObject).\
filter_by(guid=url_to_ids[location][0]).\
update({'current': False}, False)

obj.save()
ids.append(obj.id)

if len(ids) > 0:
log.debug('{0} objects sent to the next stage: {1} new, {2} change, {3} delete'.format(
len(ids), len(new), len(change), len(delete)))
Expand Down