[#5] Add new finished field for harvest job
When the run command flags a job as finished, it will query the most recent harvest object for this job and use its import_finished value as the job finishing time.
This commit is contained in:
parent
920f07cdf7
commit
42bace3628
|
@ -208,10 +208,19 @@ def harvest_jobs_run(context,data_dict):
|
||||||
objects = session.query(HarvestObject.id) \
|
objects = session.query(HarvestObject.id) \
|
||||||
.filter(HarvestObject.harvest_job_id==job['id']) \
|
.filter(HarvestObject.harvest_job_id==job['id']) \
|
||||||
.filter(and_((HarvestObject.state!=u'COMPLETE'),
|
.filter(and_((HarvestObject.state!=u'COMPLETE'),
|
||||||
(HarvestObject.state!=u'ERROR')))
|
(HarvestObject.state!=u'ERROR'))) \
|
||||||
|
.order_by(HarvestObject.import_finished.desc())
|
||||||
|
|
||||||
if objects.count() == 0:
|
if objects.count() == 0:
|
||||||
job_obj = HarvestJob.get(job['id'])
|
job_obj = HarvestJob.get(job['id'])
|
||||||
job_obj.status = u'Finished'
|
job_obj.status = u'Finished'
|
||||||
|
|
||||||
|
last_object = session.query(HarvestObject) \
|
||||||
|
.filter(HarvestObject.harvest_job_id==job['id']) \
|
||||||
|
.order_by(HarvestObject.import_finished.desc()) \
|
||||||
|
.first()
|
||||||
|
if last_object:
|
||||||
|
job_obj.finished = last_object.import_finished
|
||||||
job_obj.save()
|
job_obj.save()
|
||||||
# Reindex the harvest source dataset so it has the latest
|
# Reindex the harvest source dataset so it has the latest
|
||||||
# status
|
# status
|
||||||
|
|
|
@ -193,6 +193,7 @@ def define_harvester_tables():
|
||||||
Column('created', types.DateTime, default=datetime.datetime.utcnow),
|
Column('created', types.DateTime, default=datetime.datetime.utcnow),
|
||||||
Column('gather_started', types.DateTime),
|
Column('gather_started', types.DateTime),
|
||||||
Column('gather_finished', types.DateTime),
|
Column('gather_finished', types.DateTime),
|
||||||
|
Column('finished', types.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),
|
||||||
)
|
)
|
||||||
|
@ -380,6 +381,9 @@ ALTER TABLE harvest_source
|
||||||
ADD COLUMN frequency text,
|
ADD COLUMN frequency text,
|
||||||
ADD COLUMN next_run timestamp without time zone;
|
ADD COLUMN next_run timestamp without time zone;
|
||||||
|
|
||||||
|
ALTER TABLE harvest_job
|
||||||
|
ADD COLUMN finished timestamp without time zone;
|
||||||
|
|
||||||
ALTER TABLE harvest_object_extra
|
ALTER TABLE harvest_object_extra
|
||||||
ADD CONSTRAINT harvest_object_extra_pkey PRIMARY KEY (id);
|
ADD CONSTRAINT harvest_object_extra_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{ _('Finished') }}</th>
|
<th>{{ _('Finished') }}</th>
|
||||||
<td>?? (gather_finished, last object import_finished)</td>
|
<td>{{ c.job.finished }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in New Issue