From b59c606bca74a5cd26dd04203574940752acefd4 Mon Sep 17 00:00:00 2001 From: Alberto Islas Date: Mon, 23 Sep 2024 17:11:32 -0600 Subject: [PATCH 1/2] fix(elasticsearch): Fixed entry_date_filed display on RECAP Search results --- cl/custom_filters/templatetags/extras.py | 5 +++-- cl/lib/test_helpers.py | 2 +- cl/search/tests/tests_es_recap.py | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cl/custom_filters/templatetags/extras.py b/cl/custom_filters/templatetags/extras.py index 0a35e6ba8e..a63191495a 100644 --- a/cl/custom_filters/templatetags/extras.py +++ b/cl/custom_filters/templatetags/extras.py @@ -1,10 +1,11 @@ import random import re -from datetime import date, datetime +from datetime import datetime from django import template from django.core.exceptions import ValidationError from django.template import Context +from django.template.defaultfilters import date as date_filter from django.utils.formats import date_format from django.utils.html import format_html from django.utils.http import urlencode @@ -282,7 +283,7 @@ def format_date(date_str: str) -> str: ES child document results where dates are not date objects.""" try: date_obj = datetime.strptime(date_str, "%Y-%m-%d") - return date_obj.strftime("%B %dth, %Y") + return date_filter(date_obj, "F jS, Y") except (ValueError, TypeError): return date_str diff --git a/cl/lib/test_helpers.py b/cl/lib/test_helpers.py index 22c6b9d96c..6dfd2fccea 100644 --- a/cl/lib/test_helpers.py +++ b/cl/lib/test_helpers.py @@ -1260,7 +1260,7 @@ def setUpTestData(cls): source=Docket.COLUMBIA_AND_RECAP, ), entry_number=3, - date_filed=datetime.date(2014, 7, 19), + date_filed=datetime.date(2014, 7, 5), description="MOTION for Leave to File Amicus Discharging Debtor", ) cls.rd_2 = RECAPDocumentFactory( diff --git a/cl/search/tests/tests_es_recap.py b/cl/search/tests/tests_es_recap.py index 7730296eff..14de742c96 100644 --- a/cl/search/tests/tests_es_recap.py +++ b/cl/search/tests/tests_es_recap.py @@ -2088,10 +2088,10 @@ def test_results_ordering(self) -> None: 0, r.content.decode(), 1, "August 19th, 2015" ) self._compare_child_entry_date_filed( - 1, r.content.decode(), 0, "July 19th, 2014" + 1, r.content.decode(), 0, "July 5th, 2014" ) self._compare_child_entry_date_filed( - 2, r.content.decode(), 0, "February 23th, 1732" + 2, r.content.decode(), 0, "February 23rd, 1732" ) # Order by entry_date_filed asc @@ -2116,10 +2116,10 @@ def test_results_ordering(self) -> None: # Confirm entry date filed are properly displayed. self._compare_child_entry_date_filed( - 0, r.content.decode(), 0, "February 23th, 1732" + 0, r.content.decode(), 0, "February 23rd, 1732" ) self._compare_child_entry_date_filed( - 1, r.content.decode(), 0, "July 19th, 2014" + 1, r.content.decode(), 0, "July 5th, 2014" ) self._compare_child_entry_date_filed( 2, r.content.decode(), 0, "August 19th, 2015" From c97bf573c8ba3511a55b6912a480e1a38a122cf2 Mon Sep 17 00:00:00 2001 From: Alberto Islas Date: Mon, 23 Sep 2024 19:07:59 -0600 Subject: [PATCH 2/2] fix(elasticsearch): Complete factories empty fields to avoid collisions during search tests --- cl/search/tests/tests_es_recap.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cl/search/tests/tests_es_recap.py b/cl/search/tests/tests_es_recap.py index 14de742c96..5772e46e78 100644 --- a/cl/search/tests/tests_es_recap.py +++ b/cl/search/tests/tests_es_recap.py @@ -2887,7 +2887,9 @@ def setUpTestData(cls): cited_opinion=cls.opinion, depth=1, ) - BankruptcyInformationFactory(docket=cls.de_api.docket) + BankruptcyInformationFactory( + docket=cls.de_api.docket, trustee_str="Lorem Ipsum" + ) cls.de_empty_fields_api = DocketEntryWithParentsFactory( docket=DocketFactory( @@ -2909,6 +2911,7 @@ def setUpTestData(cls): court=cls.court_api, date_argued=None, source=Docket.RECAP_AND_IDB, + case_name_full="", ) async def _test_api_results_count( @@ -3825,6 +3828,7 @@ def test_date_filed_sorting_function_score(self) -> None: docket_entry_recent = DocketEntryWithParentsFactory( docket__source=Docket.RECAP, docket__case_name="Lorem Ipsum", + docket__case_name_full="", docket__date_filed=datetime.date(2024, 2, 23), date_filed=datetime.date(2022, 2, 23), )