[refactoring] Save gathering starting and finishing time

This commit is contained in:
Adrià Mercader 2011-04-11 16:29:47 +01:00
parent 3c505693ff
commit e2faa14b8d
2 changed files with 5 additions and 0 deletions

View File

@ -115,6 +115,8 @@ harvest_source_table = Table('harvest_source', metadata,
harvest_job_table = Table('harvest_job', metadata, harvest_job_table = Table('harvest_job', metadata,
Column('id', types.UnicodeText, primary_key=True, default=make_uuid), Column('id', types.UnicodeText, primary_key=True, default=make_uuid),
Column('created', DateTime, default=datetime.datetime.utcnow), Column('created', DateTime, default=datetime.datetime.utcnow),
Column('gather_started', DateTime),
Column('gather_finished', DateTime),
Column('source_id', types.UnicodeText, ForeignKey('harvest_source.id')), Column('source_id', types.UnicodeText, ForeignKey('harvest_source.id')),
Column('status', types.UnicodeText, default=u'New', nullable=False), Column('status', types.UnicodeText, default=u'New', nullable=False),
) )

View File

@ -79,7 +79,10 @@ def gather_callback(message_data,message):
if harvester.get_type() == job.source.type: if harvester.get_type() == job.source.type:
# 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()
harvest_object_ids = harvester.gather_stage(job) harvest_object_ids = harvester.gather_stage(job)
job.gather_finished = datetime.datetime.now()
job.save()
log.debug('Received from plugin''s gather_stage: %r' % harvest_object_ids) log.debug('Received from plugin''s gather_stage: %r' % harvest_object_ids)
if harvest_object_ids and len(harvest_object_ids) > 0: if harvest_object_ids and len(harvest_object_ids) > 0:
for id in harvest_object_ids: for id in harvest_object_ids: