Skip to content

Commit

Permalink
ignore size, start when collecting active facets
Browse files Browse the repository at this point in the history
  • Loading branch information
diversen7 committed Jul 31, 2023
1 parent 0d343cb commit 05c38b8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions stadsarkiv_client/records/normalize_facets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@


def get_records_filter(records, key) -> dict:
"""Get collector from records."""
"""Get a single filter from records"""

if not records.get("filters"):
return {}

try:
filters = records["filters"]
for filter in filters:
Expand Down Expand Up @@ -59,7 +63,6 @@ def _transform_facets(self, top_level_key, facets_content):
"""Alter the facets content with the count from the search facets. Also add
a checked key to the facets content if the facet is checked in the query_params."""
for facet in facets_content:

if "children" in facet:
self._transform_facets(top_level_key, facet["children"])

Expand All @@ -81,7 +84,6 @@ def _transform_facets(self, top_level_key, facets_content):
facet["search_query"] = self.query_str + f"{top_level_key}={facet['id']}&"

def get_checked_facets(self):

"""get a list of facets that are checked (meaning that they are working filters).
Also add a remove_query key to the facet, which is the query string without the facet.
"""
Expand All @@ -90,17 +92,16 @@ def get_checked_facets(self):
for key, value in self.facets.items():
self._transform_facets_checked(key, value["content"], self.facets_checked)

ignore_keys = ["subjects", "content_types", "usability", "availability"]
ignore_keys = ["subjects", "content_types", "usability", "availability", "size", "start"]

query_params = QUERY_PARAMS
for key, value in query_params.items():

if key not in ignore_keys and self.request.query_params.get(key):
facet = {"id": self.request.query_params.get(key)}
facet["alter_label"] = value["label"]

filter = get_records_filter(self.records, key)
if not filter.get('unresolved'):
if not filter.get("unresolved"):
facet["alter_label"] = filter.get("value")
else:
facet["alter_label"] = f"NOT RESOLVED '{key}'={facet['id']}"
Expand Down

0 comments on commit 05c38b8

Please sign in to comment.