[ckan-changes] commit/ckanext-inspire: amercader: Update harvest objects dates denominations
Bitbucket
commits-noreply at bitbucket.org
Wed May 11 16:08:51 UTC 2011
1 new changeset in ckanext-inspire:
http://bitbucket.org/okfn/ckanext-inspire/changeset/09981e78129b/
changeset: r29:09981e78129b
user: amercader
date: 2011-05-11 18:08:39
summary: Update harvest objects dates denominations
affected #: 2 files (121 bytes)
--- a/ckanext/inspire/controllers/api.py Wed May 11 16:22:24 2011 +0100
+++ b/ckanext/inspire/controllers/api.py Wed May 11 17:08:39 2011 +0100
@@ -18,15 +18,15 @@
obj = Session.query(HarvestObject) \
.filter(HarvestObject.guid==guid) \
.filter(HarvestObject.package!=None) \
- .filter(HarvestObject.reference_date!=None) \
- .order_by(HarvestObject.reference_date.desc()) \
+ .filter(HarvestObject.metadata_modified_date!=None) \
+ .order_by(HarvestObject.metadata_modified_date.desc()) \
.limit(1).first()
if not obj:
- #Just in case reference_dates have not been yet set up
+ #Just in case metadata_modified_dates have not been yet set up
obj = Session.query(HarvestObject) \
.filter(HarvestObject.guid==guid) \
.filter(HarvestObject.package!=None) \
- .order_by(HarvestObject.created.desc()) \
+ .order_by(HarvestObject.gathered.desc()) \
.limit(1).first()
return obj
--- a/ckanext/inspire/harvesters.py Wed May 11 16:22:24 2011 +0100
+++ b/ckanext/inspire/harvesters.py Wed May 11 17:08:39 2011 +0100
@@ -158,28 +158,28 @@
# Save the metadata reference date in the Harvest Object
try:
- reference_date = datetime.strptime(gemini_values['metadata-date'],'%Y-%m-%d')
+ metadata_modified_date = datetime.strptime(gemini_values['metadata-date'],'%Y-%m-%d')
except ValueError:
try:
- reference_date = datetime.strptime(gemini_values['metadata-date'],'%Y-%m-%dT%H:%M:%S')
+ metadata_modified_date = datetime.strptime(gemini_values['metadata-date'],'%Y-%m-%dT%H:%M:%S')
except:
raise Exception('Could not extract reference date for GUID %s (%s)' \
% (gemini_guid,gemini_values['metadata-date']))
- self.obj.reference_date = reference_date
+ self.obj.metadata_modified_date = metadata_modified_date
self.obj.save()
# Look for previously harvested document matching Gemini GUID
harvested_objects = Session.query(HarvestObject) \
.filter(HarvestObject.guid==gemini_guid) \
.filter(HarvestObject.package!=None) \
- .order_by(HarvestObject.reference_date.desc()).all()
+ .order_by(HarvestObject.metadata_modified_date.desc()).all()
if len(harvested_objects):
#SA returns nulls first.
last_harvested_object = harvested_objects[0]
for ho in harvested_objects:
- if ho.reference_date:
+ if ho.metadata_modified_date:
last_harvested_object = ho
break
else:
@@ -203,10 +203,10 @@
gemini_guid,
))
- # Use reference date instead of content to determine if the package
+ # Use metadata modified date instead of content to determine if the package
# needs to be updated
- if last_harvested_object.reference_date is None \
- or last_harvested_object.reference_date < self.obj.reference_date \
+ if last_harvested_object.metadata_modified_date is None \
+ or last_harvested_object.metadata_modified_date < self.obj.metadata_modified_date \
or self.force_import:
if self.force_import:
@@ -217,7 +217,7 @@
package = last_harvested_object.package
else:
if last_harvested_object.content != self.obj.content and \
- last_harvested_object.reference_date == self.obj.reference_date:
+ last_harvested_object.metadata_modified_date == self.obj.metadata_modified_date:
raise Exception('The contents of document with GUID %s changed, but the metadata date has not been updated' % gemini_guid)
else:
# The content hasn't changed, no need to update the package
Repository URL: https://bitbucket.org/okfn/ckanext-inspire/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list