Skip to content
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
14 changes: 4 additions & 10 deletions src/infra/infrastructure/services/conflation_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,11 @@ def merge_fkb_osm(self, release: str, theme: Theme, ids: pd.DataFrame) -> Dict[s
ids_fkb = ids[ids["fkb_id"].notna()]["fkb_id"].to_list()
ids_osm = ids[ids["fkb_id"].isna() & ids["osm_id"].notna()]["osm_id"].to_list()

fkb_filter = (
"FALSE"
if not ids_fkb
else f'external_id IN ({", ".join(f"'{v}'" for v in ids_fkb)})'
)
ids_fkb_str = ", ".join(f"'{v}'" for v in ids_fkb)
ids_osm_str = ", ".join(f"'{v}'" for v in ids_osm)
Comment on lines +181 to +182
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The string joining operations are performed unconditionally, even when ids_fkb or ids_osm are empty lists. This creates unnecessary string operations that won't be used when the filters evaluate to "FALSE". Consider moving the join operations inside the ternary expressions or using lazy evaluation to avoid this overhead.

Example:

fkb_filter = "FALSE" if not ids_fkb else f"external_id IN ({', '.join(f\"'{v}'\" for v in ids_fkb)})"
osm_filter = "FALSE" if not ids_osm else f"external_id IN ({', '.join(f\"'{v}'\" for v in ids_osm)})"

Copilot uses AI. Check for mistakes.

osm_filter = (
"FALSE"
if not ids_osm
else f'external_id IN ({", ".join(f"'{v}'" for v in ids_osm)})'
)
fkb_filter = "FALSE" if not ids_fkb else f"external_id IN ({ids_fkb_str})"
osm_filter = "FALSE" if not ids_osm else f"external_id IN ({ids_osm_str})"

df = self.__db_context.execute(
f'''
Expand Down
Loading