From 100062d8d4f48c8bab967bcdbe930fd2aef481cb Mon Sep 17 00:00:00 2001 From: ismailshahzad Date: Fri, 4 Sep 2020 13:47:35 +0500 Subject: [PATCH 1/2] [_json.py] Appends obj.id after saving --- ckanext/dcat/harvesters/_json.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ckanext/dcat/harvesters/_json.py b/ckanext/dcat/harvesters/_json.py index d4a025ef..a81d2c1a 100644 --- a/ckanext/dcat/harvesters/_json.py +++ b/ckanext/dcat/harvesters/_json.py @@ -165,11 +165,8 @@ def gather_stage(self, harvest_job): guid=guid, job=harvest_job, package_id=guid_to_package_id[guid], extras=[HarvestObjectExtra(key='status', value='delete')]) - ids.append(obj.id) - model.Session.query(HarvestObject).\ - filter_by(guid=guid).\ - update({'current': False}, False) obj.save() + ids.append(obj.id) return ids @@ -196,6 +193,10 @@ def import_stage(self, harvest_object): context, {'id': harvest_object.package_id}) log.info('Deleted package {0} with guid {1}' .format(harvest_object.package_id, harvest_object.guid)) + + model.Session.query(HarvestObject).\ + filter_by(guid=guid).\ + update({'current': False}, False) return True From 863701e7f9da337dbd9f7b7b1fa0014203b37ba0 Mon Sep 17 00:00:00 2001 From: ismailshahzad Date: Fri, 4 Sep 2020 23:34:11 +0500 Subject: [PATCH 2/2] [harvesters/_json.py] Fixes the guid parameter for filtering the model session query --- ckanext/dcat/harvesters/_json.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ckanext/dcat/harvesters/_json.py b/ckanext/dcat/harvesters/_json.py index a81d2c1a..5e2d5c2d 100644 --- a/ckanext/dcat/harvesters/_json.py +++ b/ckanext/dcat/harvesters/_json.py @@ -193,9 +193,10 @@ def import_stage(self, harvest_object): context, {'id': harvest_object.package_id}) log.info('Deleted package {0} with guid {1}' .format(harvest_object.package_id, harvest_object.guid)) - + model.Session.query(HarvestObject).\ - filter_by(guid=guid).\ + filter_by(guid=harvest_object.guid).\ + filter_by(current=True).\ update({'current': False}, False) return True