Skip to content

Commit

Permalink
feat(search): Improves data transformation to handle missing fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ERosendo committed Mar 11, 2025
1 parent b6e5350 commit e26cb76
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cl/search/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,8 +1254,10 @@ def get_csv_transformations(cls) -> dict[str, Callable[..., Any]]:
transformations["filepath_local"] = lambda x: (
f"https://storage.courtlistener.com/{x}" if x else ""
)
transformations["rd_absolute_url"] = (
lambda x: f"https://www.courtlistener.com{x['absolute_url']}"
transformations["rd_absolute_url"] = lambda x: (
f"https://www.courtlistener.com{x['absolute_url']}"
if x.get("absolute_url")
else ""
)

# Define a mapping of new CSV column names to the corresponding source
Expand All @@ -1277,7 +1279,8 @@ def get_csv_transformations(cls) -> dict[str, Callable[..., Any]]:
# the value from the source key in the input data.
for new_key, source in new_keys_mapping.items():
transformations[new_key] = partial(
lambda origin_key, document: document[origin_key], source
lambda origin_key, document: document.get(origin_key, ""),
source,
)
return transformations

Expand Down

0 comments on commit e26cb76

Please sign in to comment.