From 07734cfebd6d670992fe29b3d925214df91587dd Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Thu, 22 Feb 2024 14:23:06 +0100 Subject: [PATCH] fix: hofstaat, remove facet from owners and add kategorie --- viecpro_typesense/collections.py | 8 +++++++- viecpro_typesense/fields.py | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/viecpro_typesense/collections.py b/viecpro_typesense/collections.py index 6ba909a..63be457 100644 --- a/viecpro_typesense/collections.py +++ b/viecpro_typesense/collections.py @@ -98,6 +98,11 @@ def labelhandler(x): return [label.label for label in labels if label.label_type.name in label_types] +def kategorienhandler(x): + labels = x.label_set.all() + return [label.label for label in labels if label.label_type.name == "Kategorie"] + + def create_entity_collections(): res = [] for m in AbstractEntity.get_all_entity_classes(): @@ -204,7 +209,8 @@ def queryset(): return Institution.objects.filter(kind__name="Hofstaat") # Maybe need to change model to hofstaat here model = StaticField(value="Hofstaat", options=O(facet=True)) kind = KindField("kind", options=O(facet=True)) - labels = LabelsNestedObjectField("id", pass_instance=True) + labels = LabelsNestedObjectField("id", pass_instance=True, options=O(facet=False)) + kategorie = Field("kategorie", options=O(type="string[]", facet=True, optional=True), handler=kategorienhandler, pass_instance=True) def unified_fields(m): return { diff --git a/viecpro_typesense/fields.py b/viecpro_typesense/fields.py index 1d28c4c..1dc6377 100644 --- a/viecpro_typesense/fields.py +++ b/viecpro_typesense/fields.py @@ -5,13 +5,13 @@ class MainOwnerField(Field): class Config: - options = O(type="object", optional=True, facet=True) + options = O(type="object", optional=True, facet=False) handler = MainOwnerFieldHandler class HofstaatsinhaberField(Field): class Config: - options = O(type="object[]", optional=True, facet=True) + options = O(type="object[]", optional=True, facet=False) handler = HofstaatsinhaberHandler