[lib] Ignore deleted packages in source stats
This commit is contained in:
parent
3a489bbb82
commit
a997e45470
|
@ -88,7 +88,8 @@ def _get_source_status(source, detailed=True):
|
||||||
# Overall statistics
|
# Overall statistics
|
||||||
packages = Session.query(distinct(HarvestObject.package_id),Package.name) \
|
packages = Session.query(distinct(HarvestObject.package_id),Package.name) \
|
||||||
.join(Package).join(HarvestJob).join(HarvestSource) \
|
.join(Package).join(HarvestJob).join(HarvestSource) \
|
||||||
.filter(HarvestJob.source==source)
|
.filter(HarvestJob.source==source) \
|
||||||
|
.filter(Package.state==u'active')
|
||||||
|
|
||||||
out['overall_statistics']['added'] = packages.count()
|
out['overall_statistics']['added'] = packages.count()
|
||||||
if detailed:
|
if detailed:
|
||||||
|
@ -348,17 +349,23 @@ def import_last_objects(source_id=None):
|
||||||
if not source:
|
if not source:
|
||||||
raise NotFound('Harvest source %s does not exist' % source_id)
|
raise NotFound('Harvest source %s does not exist' % source_id)
|
||||||
|
|
||||||
|
if not source.active:
|
||||||
|
raise Exception('This harvest source is not active')
|
||||||
|
|
||||||
last_objects_ids = Session.query(HarvestObject.id) \
|
last_objects_ids = Session.query(HarvestObject.id) \
|
||||||
.join(HarvestJob) \
|
.join(HarvestJob).join(Package) \
|
||||||
.filter(HarvestJob.source==source) \
|
.filter(HarvestJob.source==source) \
|
||||||
.filter(HarvestObject.package!=None) \
|
.filter(HarvestObject.package!=None) \
|
||||||
|
.filter(Package.state==u'active') \
|
||||||
.order_by(HarvestObject.guid) \
|
.order_by(HarvestObject.guid) \
|
||||||
.order_by(HarvestObject.metadata_modified_date.desc()) \
|
.order_by(HarvestObject.metadata_modified_date.desc()) \
|
||||||
.order_by(HarvestObject.gathered.desc()) \
|
.order_by(HarvestObject.gathered.desc()) \
|
||||||
.all()
|
.all()
|
||||||
else:
|
else:
|
||||||
last_objects_ids = Session.query(HarvestObject.id) \
|
last_objects_ids = Session.query(HarvestObject.id) \
|
||||||
|
.join(Package) \
|
||||||
.filter(HarvestObject.package!=None) \
|
.filter(HarvestObject.package!=None) \
|
||||||
|
.filter(Package.state==u'active') \
|
||||||
.order_by(HarvestObject.guid) \
|
.order_by(HarvestObject.guid) \
|
||||||
.order_by(HarvestObject.metadata_modified_date.desc()) \
|
.order_by(HarvestObject.metadata_modified_date.desc()) \
|
||||||
.order_by(HarvestObject.gathered.desc()) \
|
.order_by(HarvestObject.gathered.desc()) \
|
||||||
|
|
Loading…
Reference in New Issue