[#50] Save all dates as UTC in the database

At some point we may want to transform these to local time at the
dictization level. We will need a library like dateutil to handle it
properly though.
This commit is contained in:
amercader 2013-07-04 14:59:27 +01:00
parent c2283e3fdb
commit e2696b98bb
1 changed files with 6 additions and 6 deletions

View File

@ -211,7 +211,7 @@ def gather_callback(channel, method, header, body):
if harvester.info()['name'] == job.source.type: if harvester.info()['name'] == job.source.type:
harvester_found = True harvester_found = True
# Get a list of harvest object ids from the plugin # Get a list of harvest object ids from the plugin
job.gather_started = datetime.datetime.now() job.gather_started = datetime.datetime.utcnow()
try: try:
harvest_object_ids = harvester.gather_stage(job) harvest_object_ids = harvester.gather_stage(job)
@ -222,7 +222,7 @@ def gather_callback(channel, method, header, body):
).delete() ).delete()
raise raise
finally: finally:
job.gather_finished = datetime.datetime.now() job.gather_finished = datetime.datetime.utcnow()
job.save() job.save()
if not isinstance(harvest_object_ids, list): if not isinstance(harvest_object_ids, list):
@ -292,19 +292,19 @@ def fetch_callback(channel, method, header, body):
channel.basic_ack(method.delivery_tag) channel.basic_ack(method.delivery_tag)
def fetch_and_import_stages(harvester, obj): def fetch_and_import_stages(harvester, obj):
obj.fetch_started = datetime.datetime.now() obj.fetch_started = datetime.datetime.utcnow()
obj.state = "FETCH" obj.state = "FETCH"
obj.save() obj.save()
success_fetch = harvester.fetch_stage(obj) success_fetch = harvester.fetch_stage(obj)
obj.fetch_finished = datetime.datetime.now() obj.fetch_finished = datetime.datetime.utcnow()
obj.save() obj.save()
if success_fetch: if success_fetch:
# If no errors where found, call the import method # If no errors where found, call the import method
obj.import_started = datetime.datetime.now() obj.import_started = datetime.datetime.utcnow()
obj.state = "IMPORT" obj.state = "IMPORT"
obj.save() obj.save()
success_import = harvester.import_stage(obj) success_import = harvester.import_stage(obj)
obj.import_finished = datetime.datetime.now() obj.import_finished = datetime.datetime.utcnow()
if success_import: if success_import:
obj.state = "COMPLETE" obj.state = "COMPLETE"
else: else: