Python formatting
This commit is contained in:
parent
5d3639e47f
commit
59643c02a3
|
@ -131,8 +131,9 @@ def search_identifiers(query, *filters):
|
||||||
parent_work=OuterRef("parent_work")
|
parent_work=OuterRef("parent_work")
|
||||||
).order_by("-edition_rank")
|
).order_by("-edition_rank")
|
||||||
return (
|
return (
|
||||||
results.annotate(default_id=Subquery(default_editions.values("id")[:1]))
|
results.annotate(default_id=Subquery(default_editions.values("id")[:1])).filter(
|
||||||
.filter(default_id=F("id"))
|
default_id=F("id")
|
||||||
|
)
|
||||||
or results
|
or results
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -147,17 +148,13 @@ def search_title_author(query, min_confidence, *filters):
|
||||||
)
|
)
|
||||||
|
|
||||||
results = (
|
results = (
|
||||||
models.Edition.objects
|
models.Edition.objects.annotate(rank=SearchRank(vector, query))
|
||||||
.annotate(rank=SearchRank(vector, query))
|
|
||||||
.filter(*filters, rank__gt=min_confidence)
|
.filter(*filters, rank__gt=min_confidence)
|
||||||
.order_by("-rank")
|
.order_by("-rank")
|
||||||
)
|
)
|
||||||
|
|
||||||
# when there are multiple editions of the same work, pick the closest
|
# when there are multiple editions of the same work, pick the closest
|
||||||
editions_of_work = (
|
editions_of_work = results.values("parent_work__id").values_list("parent_work__id")
|
||||||
results.values("parent_work__id")
|
|
||||||
.values_list("parent_work__id")
|
|
||||||
)
|
|
||||||
|
|
||||||
# filter out multiple editions of the same work
|
# filter out multiple editions of the same work
|
||||||
for work_id in set(editions_of_work):
|
for work_id in set(editions_of_work):
|
||||||
|
|
Loading…
Reference in New Issue