Skip to content

Commit

Permalink
fix: document count logic and ensure valid sort dates.
Browse files Browse the repository at this point in the history
Updated the initial value of `inserted_document_count` to 1 to more accurately reflect insertion logic. Introduced `valid_sort_date` in `legislation.py` to default to `modified` date if `valid` date is missing or empty, ensuring correct sorting behavior.
  • Loading branch information
hareshkainthdbt committed Dec 3, 2024
1 parent a900886 commit 5832843
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions fbr/cache/legislation.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ def _to_json(
Returns:
dict: A dictionary containing the item details in a structured format.
"""

valid_sort_date = modified if valid is None or valid == "" else valid

return {
"id": generate_short_uuid(),
"title": title,
Expand All @@ -233,8 +236,8 @@ def _to_json(
"description": description if description is not None else "",
"date_issued": convert_date_string_to_obj(modified),
"date_modified": convert_date_string_to_obj(modified),
"date_valid": valid,
"sort_date": convert_date_string_to_obj(valid),
"date_valid": valid_sort_date,
"sort_date": valid_sort_date,
"type": "Legislation",
"score": 0,
}
2 changes: 1 addition & 1 deletion fbr/cache/public_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def build_cache(self, config):
# Now you can use `data` as a usual Python dictionary
# Convert each row into DataResponseModel object
total_documents = len(data.get("uk_regulatory_documents"))
inserted_document_count = 0
inserted_document_count = 1
for row in data.get("uk_regulatory_documents"):
logger.info(
f"inserting or updating document "
Expand Down

0 comments on commit 5832843

Please sign in to comment.