Refactored tag filtering in StoreService
This commit is contained in:
parent
7b19cce2f7
commit
29409aec51
1 changed files with 12 additions and 10 deletions
|
|
@ -144,11 +144,12 @@ class StoreService(Service):
|
||||||
filter_conditions.append({"is_component": {"_eq": is_component}})
|
filter_conditions.append({"is_component": {"_eq": is_component}})
|
||||||
|
|
||||||
if tags:
|
if tags:
|
||||||
filter_conditions.append({"tags": {"tags_id": {"name": {"_in": tags}}}})
|
tags_filter = {"tags": {"_and": []}}
|
||||||
# tags_filter = {"tags": {"_or": []}}
|
for tag in tags:
|
||||||
# for tag in tags:
|
tags_filter["tags"]["_and"].append(
|
||||||
# tags_filter["tags"]["_or"].append({"tags_id": {"name": {"_eq": tag}}})
|
{"_some": {"tags_id": {"name": {"_eq": tag}}}}
|
||||||
# filter_conditions.append(tags_filter)
|
)
|
||||||
|
filter_conditions.append(tags_filter)
|
||||||
|
|
||||||
if date_from:
|
if date_from:
|
||||||
# params["filter[date_updated][_gte]"] = date_from.isoformat()
|
# params["filter[date_updated][_gte]"] = date_from.isoformat()
|
||||||
|
|
@ -247,11 +248,12 @@ class StoreService(Service):
|
||||||
filter_conditions.append({"status": {"_eq": status}})
|
filter_conditions.append({"status": {"_eq": status}})
|
||||||
|
|
||||||
if tags:
|
if tags:
|
||||||
filter_conditions.append({"tags": {"tags_id": {"name": {"_in": tags}}}})
|
tags_filter = {"tags": {"_and": []}}
|
||||||
# tags_filter = {"tags": {"_or": []}}
|
for tag in tags:
|
||||||
# for tag in tags:
|
tags_filter["tags"]["_and"].append(
|
||||||
# tags_filter["tags"]["_or"].append({"tags_id": {"name": {"_eq": tag}}})
|
{"_some": {"tags_id": {"name": {"_eq": tag}}}}
|
||||||
# filter_conditions.append(tags_filter)
|
)
|
||||||
|
filter_conditions.append(tags_filter)
|
||||||
|
|
||||||
if is_component is not None:
|
if is_component is not None:
|
||||||
filter_conditions.append({"is_component": {"_eq": is_component}})
|
filter_conditions.append({"is_component": {"_eq": is_component}})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue