From eadeb27c0a3c51152a83de869083c31d8d250123 Mon Sep 17 00:00:00 2001 From: sniedzielski <52816247+sniedzielski@users.noreply.github.com> Date: Mon, 10 Jun 2024 15:23:10 +0200 Subject: [PATCH] CM-830: access basic data about grievances (for example number of grievances) (#18) * CM-830: added grievance for opensearch reporting layer * CM-830: removed processing json ext --- grievance_social_protection/documents.py | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 grievance_social_protection/documents.py diff --git a/grievance_social_protection/documents.py b/grievance_social_protection/documents.py new file mode 100644 index 0000000..240225f --- /dev/null +++ b/grievance_social_protection/documents.py @@ -0,0 +1,37 @@ +from django.apps import apps + +# Check if the 'opensearch_reports' app is in INSTALLED_APPS +if 'opensearch_reports' in apps.app_configs: + from django_opensearch_dsl import Document, fields as opensearch_fields + from django_opensearch_dsl.registries import registry + from grievance_social_protection.models import Ticket + + @registry.register_document + class TicketDocument(Document): + key = opensearch_fields.KeywordField(), + title = opensearch_fields.KeywordField(), + + description = opensearch_fields.KeywordField(), + code = opensearch_fields.KeywordField(), + attending_staff = opensearch_fields.KeywordField(), + status = opensearch_fields.KeywordField(), + + category = opensearch_fields.KeywordField(), + flags = opensearch_fields.KeywordField(), + channel = opensearch_fields.KeywordField(), + resolution = opensearch_fields.KeywordField(), + + class Index: + name = 'ticket' + settings = { + 'number_of_shards': 1, + 'number_of_replicas': 0 + } + auto_refresh = True + + class Django: + model = Ticket + fields = [ + 'id', 'key', 'title', 'code' + ] + queryset_pagination = 5000