From 2d08ab254de999e10303f2282ddc3bb08658f7e4 Mon Sep 17 00:00:00 2001 From: Phil Reese Date: Thu, 25 Jul 2024 09:29:40 -0400 Subject: [PATCH] EREGCSC-2771 -- Updating front end field/display mappings (#1378) * chore: udpate gitignore to ignore db backups * feat: add internal link post save method * feat: update front end to show docID for internal items * feat: further refinement of internal doc field/display mappings --- solution/backend/content_search/models.py | 17 ++++++++++++++--- .../src/components/subjects/PolicyResults.vue | 15 +++++++-------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/solution/backend/content_search/models.py b/solution/backend/content_search/models.py index 565517d7e3..2678bfa642 100644 --- a/solution/backend/content_search/models.py +++ b/solution/backend/content_search/models.py @@ -124,8 +124,7 @@ def get_or_create_index(instance, created): @receiver(post_save, sender=PublicLink) @receiver(post_save, sender=FederalRegisterLink) -@receiver(post_save, sender=InternalLink) -def update_indexed_resource(sender, instance, created, **kwargs): +def update_indexed_public_resource(sender, instance, created, **kwargs): index = get_or_create_index(instance, created) index.name = instance.document_id index.summary = instance.title @@ -140,7 +139,7 @@ def update_indexed_resource(sender, instance, created, **kwargs): @receiver(post_save, sender=InternalFile) -def update_indexed_file(sender, instance, created, **kwargs): +def update_indexed_internal_file(sender, instance, created, **kwargs): index = get_or_create_index(instance, created) index.name = instance.title index.summary = instance.summary @@ -154,6 +153,18 @@ def update_indexed_file(sender, instance, created, **kwargs): index.save() +@receiver(post_save, sender=InternalLink) +def update_indexed_internal_link(sender, instance, created, **kwargs): + index = get_or_create_index(instance, created) + index.name = instance.title + index.summary = instance.summary + index.rank_a_string = instance.title + index.rank_b_string = instance.summary + index.rank_c_string = instance.date + index.rank_d_string = " ".join([str(i) for i in instance.subjects.all()]) + index.save() + + @receiver(post_save, sender=Part) def update_indexed_part(sender, instance, created, **kwargs): pass diff --git a/solution/ui/regulations/eregs-vite/src/components/subjects/PolicyResults.vue b/solution/ui/regulations/eregs-vite/src/components/subjects/PolicyResults.vue index 9e247a8082..1a54896f49 100644 --- a/solution/ui/regulations/eregs-vite/src/components/subjects/PolicyResults.vue +++ b/solution/ui/regulations/eregs-vite/src/components/subjects/PolicyResults.vue @@ -71,7 +71,10 @@ const showResultSnippet = (item) => { if ( DOCUMENT_TYPES_MAP[getFieldVal({ item, fieldName: "type" })] === "Internal" && - (item.content_headline || item.summary_headline || item.summary_string) + (item.content_headline || + item.summary_headline || + item.summary_string || + item.summary) ) return true; @@ -101,6 +104,8 @@ const getResultSnippet = (item) => { snippet = addSurroundingEllipses(item.summary_headline); } else if (item.summary_string) { snippet = item.summary_string; + } else if (item.summary) { + snippet = item.summary; } return snippet; @@ -183,7 +188,6 @@ const getUrl = ({ type: resourceType, url, uid }) => : url; const needsBar = (item) => - DOCUMENT_TYPES_MAP[getFieldVal({ item, fieldName: "type" })] === "Public" && getFieldVal({ item, fieldName: "date" }) && getFieldVal({ item, fieldName: "document_id" }); @@ -358,12 +362,7 @@ const currentPageResultsRange = getCurrentPageResultsRange({ :division="doc.division" /--> {{ getFieldVal({ item: doc, fieldName: "document_id" }) }}