Klappe Geizhals-Filtergruppen beim Lernen auf und nimm neue Kategorien ueber den Quellpfad auf.
Deploy Development / deploy (push) Successful in 1m34s
Test Suite / pytest-backend (push) Failing after 16s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-checks (push) Successful in 33s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-04 15:04:19 +02:00
1 parent 46857715df
commit 2117ca6b54
10 files changed
+203 -25

No files matched your search

+27
View File
@@ -67,6 +67,33 @@ class CatalogService:
for row in rows
]
def register_source_category(self, source_id: str, payload: dict[str, Any]) -> dict[str, Any]:
if self.catalog.get_source(source_id) is None:
raise AppError(404, "NOT_FOUND", "source not found", {"source_id": source_id})
from app.sources.geizhals.category_url import parse_category_key, slugify
from app.services.discovery_service import TaxonomyService
source_url = str(payload["source_url"]).strip()
category_key = parse_category_key(source_url)
name = str(payload.get("name") or category_key)
product_category_id = str(payload.get("product_category_id") or slugify(name))
ensure_product_category(self.session, product_category_id, str(payload.get("product_category_name") or name))
category = ensure_source_category(
self.session,
source_id=source_id,
external_category_key=category_key,
product_category_id=product_category_id,
name=name,
source_url=source_url,
)
category.source_url = source_url
category.name = name
category.product_category_id = product_category_id
self.session.flush()
TaxonomyService(self.session).discover(source_id, category_key)
items = self.source_categories(source_id)
return next(item for item in items if item["external_category_key"] == category_key)
def source_categories(self, source_id: str) -> list[dict[str, Any]]:
if self.catalog.get_source(source_id) is None:
raise AppError(404, "NOT_FOUND", "source not found", {"source_id": source_id})
+11
View File
@@ -100,7 +100,18 @@ class TaxonomyService:
if catalog.get_source(source_id) is None:
raise AppError(404, "NOT_FOUND", "source not found", {"source_id": source_id})
adapter = self.adapter or discovery_adapter(source_id)
existing = self.session.scalars(
select(SourceCategoryRecord).where(
SourceCategoryRecord.source_id == source_id,
SourceCategoryRecord.external_category_key == category_key,
)
).first()
try:
payload = adapter.discover_taxonomy(
category_key,
source_url=None if existing is None else existing.source_url,
)
except TypeError:
payload = adapter.discover_taxonomy(category_key)
except AppError as exc:
category = self.session.scalars(