Optional isa_filter for wikidata_isa_counts

This commit is contained in:
Edward Betts 2022-04-18 12:25:38 +01:00
parent 87005dea18
commit 302da85e33

View file

@ -418,7 +418,7 @@ def wikidata_items_count(bounds, isa_filter=None):
return q.count()
def wikidata_isa_counts(bounds):
def wikidata_isa_counts(bounds, isa_filter=None):
db_bbox = make_envelope(bounds)
q = (
@ -426,6 +426,9 @@ def wikidata_isa_counts(bounds):
.filter(func.ST_Covers(db_bbox, model.ItemLocation.location))
)
if isa_filter:
q = add_isa_filter(q, isa_filter)
db_items = q.all()
counts = get_isa_count(db_items)