Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add legal date formats #5533

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions webservices/resources/legal.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"admin_fines",
]

ACCEPTED_DATE_FORMATS = "strict_date_optional_time_nanos||MM/dd/yyyy||M/d/yyyy||MM/d/yyyy||M/dd/yyyy"

# endpoint path: /legal/docs/<doc_type>/<no>
# test urls:
Expand All @@ -56,6 +57,7 @@
# http://127.0.0.1:5000/v1/legal/docs/adrs/1091/
# http://127.0.0.1:5000/v1/legal/docs/admin_fines/4399/


# TODO: add this endpoint to swagger
@doc(
tags=["legal"],
Expand Down Expand Up @@ -270,6 +272,7 @@ def apply_af_specific_query_params(query, **kwargs):
if kwargs.get("af_max_rtb_date"):
date_range["lte"] = kwargs.get("af_max_rtb_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", reason_to_believe_action_date=date_range))

date_range = {}
Expand All @@ -278,6 +281,7 @@ def apply_af_specific_query_params(query, **kwargs):
if kwargs.get("af_max_fd_date"):
date_range["lte"] = kwargs.get("af_max_fd_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", final_determination_date=date_range))

if kwargs.get("af_rtb_fine_amount"):
Expand Down Expand Up @@ -319,6 +323,7 @@ def apply_mur_specific_query_params(query, **kwargs):
if kwargs.get("case_max_open_date"):
date_range["lte"] = kwargs.get("case_max_open_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", open_date=date_range))

date_range = {}
Expand All @@ -327,6 +332,7 @@ def apply_mur_specific_query_params(query, **kwargs):
if kwargs.get("case_max_close_date"):
date_range["lte"] = kwargs.get("case_max_close_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", close_date=date_range))

query = query.query("bool", must=must_clauses)
Expand Down Expand Up @@ -453,6 +459,7 @@ def apply_adr_specific_query_params(query, **kwargs):
if kwargs.get("case_max_open_date"):
date_range["lte"] = kwargs.get("case_max_open_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", open_date=date_range))

date_range = {}
Expand All @@ -461,6 +468,7 @@ def apply_adr_specific_query_params(query, **kwargs):
if kwargs.get("case_max_close_date"):
date_range["lte"] = kwargs.get("case_max_close_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", close_date=date_range))

query = query.query("bool", must=must_clauses)
Expand Down Expand Up @@ -645,6 +653,7 @@ def apply_ao_specific_query_params(query, **kwargs):
if kwargs.get("ao_max_issue_date"):
date_range["lte"] = kwargs.get("ao_max_issue_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", issue_date=date_range))

date_range = {}
Expand All @@ -653,6 +662,7 @@ def apply_ao_specific_query_params(query, **kwargs):
if kwargs.get("ao_max_request_date"):
date_range["lte"] = kwargs.get("ao_max_request_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", request_date=date_range))

if kwargs.get("ao_entity_name"):
Expand Down