Lerne Taxonomie und Trefferliste live von Geizhals, damit Wizard und Kandidaten echte Quelldaten nutzen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
d784248e28
commit
46857715df
25 files changed
+1614
-27
No files matched your search
@@ -100,7 +100,7 @@ class CatalogService:
|
||||
SourceCategoryRecord.product_category_id == product_category_id,
|
||||
)
|
||||
).first()
|
||||
if source_category is not None and source_category.taxonomy_status == TaxonomyStatus.NOT_LEARNED.value:
|
||||
if source_category is not None and self._should_learn(source_category, source_id):
|
||||
from app.services.discovery_service import TaxonomyService
|
||||
|
||||
TaxonomyService(self.session).discover(source_id, source_category.external_category_key)
|
||||
@@ -172,7 +172,33 @@ class CatalogService:
|
||||
if definition.id in seen:
|
||||
continue
|
||||
criteria.append(self._criterion_out(definition, None, None, [], None))
|
||||
return jsonable({"product_category_id": product_category_id, "source": source_id, "criteria": criteria})
|
||||
return jsonable(
|
||||
{
|
||||
"product_category_id": product_category_id,
|
||||
"source": source_id,
|
||||
"taxonomy_status": None if source_category is None else source_category.taxonomy_status,
|
||||
"criteria": criteria,
|
||||
}
|
||||
)
|
||||
|
||||
def _should_learn(self, source_category: SourceCategoryRecord, source_id: str) -> bool:
|
||||
if source_category.taxonomy_status == TaxonomyStatus.NOT_LEARNED.value:
|
||||
return True
|
||||
if source_category.taxonomy_status != TaxonomyStatus.READY.value:
|
||||
return False
|
||||
from app.settings import get_settings
|
||||
|
||||
if get_settings().geizhals_use_fixtures or source_id != "geizhals":
|
||||
return False
|
||||
keys = {
|
||||
row.external_filter_key
|
||||
for row in self.session.scalars(
|
||||
select(SourceFilterDefinitionRecord).where(
|
||||
SourceFilterDefinitionRecord.source_category_id == source_category.id
|
||||
)
|
||||
)
|
||||
}
|
||||
return keys <= {"17023", "price"}
|
||||
|
||||
def list_templates(self) -> list[dict[str, Any]]:
|
||||
rows, _total = self.catalog.list_profiles(200, 0)
|
||||
|
||||
Reference in new issue
Block a user