From 10c71855b4f7e9a0253280efe0a9d145b73e087b Mon Sep 17 00:00:00 2001 From: Yves Gugger Date: Thu, 11 Dec 2025 20:19:26 +0100 Subject: [PATCH] fix: Correct indentation in TLD aggregator - Fix indentation in _ensure_tld_info method - Fix nested if blocks for TLD type handling --- .../app/services/tld_scraper/aggregator.py | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/backend/app/services/tld_scraper/aggregator.py b/backend/app/services/tld_scraper/aggregator.py index 338e244..9775fd6 100644 --- a/backend/app/services/tld_scraper/aggregator.py +++ b/backend/app/services/tld_scraper/aggregator.py @@ -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