fix(proxy): skip the key metadata lookup when the daily rows carry no keys

This commit is contained in:
mateo-berri 2026-11-06 07:35:46 -08:00
parent 2c32b2d554
commit d7d7ef02da

View file

@ -927,6 +927,8 @@ async def _key_metadata_unless_database_fails(
rows: Sequence[GroupingSetsRow] | Sequence[EntityRollupRow] | Sequence[DailySpendRecord],
) -> Mapping[str, KeyMetadataRow] | None:
api_keys: Final = frozenset(row.api_key for row in rows if row.api_key and row.api_key != PTU_SENTINEL_API_KEY)
if not api_keys:
return MappingProxyType({})
return await unless_database_fails(
repository.key_metadata(api_keys, spend_logs_window(frozenset(row.date for row in rows))),
None,