fix: Correct indentation in TLD aggregator

- Fix indentation in _ensure_tld_info method
- Fix nested if blocks for TLD type handling
This commit is contained in:
2025-12-11 20:19:26 +01:00
parent 526428565b
commit 048f42e876

View File

@ -166,7 +166,7 @@ class TLDPriceAggregator:
# Also update/create TLDInfo if it doesn't exist (only once per TLD)
if price_data.tld not in ensured_tlds:
await self._ensure_tld_info(db, price_data.tld)
await self._ensure_tld_info(db, price_data.tld)
ensured_tlds.add(price_data.tld)
except Exception as e:
@ -179,19 +179,19 @@ class TLDPriceAggregator:
async def _ensure_tld_info(self, db: AsyncSession, tld: str):
"""Ensure TLDInfo record exists for this TLD."""
try:
result = await db.execute(
select(TLDInfo).where(TLDInfo.tld == tld)
)
existing = result.scalar_one_or_none()
if not existing:
# Create basic TLDInfo record
tld_type = self._guess_tld_type(tld)
info = TLDInfo(
tld=tld,
type=tld_type,
result = await db.execute(
select(TLDInfo).where(TLDInfo.tld == tld)
)
db.add(info)
existing = result.scalar_one_or_none()
if not existing:
# Create basic TLDInfo record
tld_type = self._guess_tld_type(tld)
info = TLDInfo(
tld=tld,
type=tld_type,
)
db.add(info)
await db.flush() # Flush immediately to catch duplicates
except Exception as e:
# Ignore duplicate key errors - TLD already exists