Schliesse das Notebook-Source-Mapping, damit Wizard und Taxonomie ohne leere Kategorie starten.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b276758ee1
commit
d784248e28
13 files changed
+1505
-9
No files matched your search
@@ -21,6 +21,7 @@ from app.discovery.enums import (
|
||||
RankingStatus,
|
||||
RunStatus,
|
||||
SearchStatus,
|
||||
TaxonomyStatus,
|
||||
)
|
||||
from app.discovery.identity import IdentitySignals, decide_identity, spec_fingerprint
|
||||
from app.discovery.mapping import verify_roundtrip
|
||||
@@ -116,6 +117,8 @@ class TaxonomyService:
|
||||
canonical_category=payload.get("canonical_category"),
|
||||
product_category_id=_linked_product_category(self.session, payload.get("canonical_category")),
|
||||
status="ACTIVE",
|
||||
taxonomy_status=TaxonomyStatus.LEARNING.value,
|
||||
last_taxonomy_scan_at=now,
|
||||
last_verified_at=now,
|
||||
)
|
||||
self.session.add(category)
|
||||
@@ -126,6 +129,8 @@ class TaxonomyService:
|
||||
if payload.get("canonical_category"):
|
||||
category.canonical_category = payload.get("canonical_category")
|
||||
category.product_category_id = _linked_product_category(self.session, payload.get("canonical_category"))
|
||||
category.taxonomy_status = TaxonomyStatus.LEARNING.value
|
||||
category.last_taxonomy_scan_at = now
|
||||
category.last_verified_at = now
|
||||
for raw in payload.get("filters") or []:
|
||||
filt = self.session.scalars(
|
||||
@@ -156,9 +161,33 @@ class TaxonomyService:
|
||||
self._sync_options(filt, raw.get("options") or [])
|
||||
if raw.get("range"):
|
||||
self._sync_range(filt, raw["range"])
|
||||
category.taxonomy_status = (
|
||||
TaxonomyStatus.READY.value if payload.get("filters") else TaxonomyStatus.BROKEN.value
|
||||
)
|
||||
self.session.flush()
|
||||
return self.filters(source_id, category.external_category_key)
|
||||
|
||||
def taxonomy_status(self, source_id: str, category_key: str) -> dict[str, Any]:
|
||||
category = self._category(source_id, category_key)
|
||||
filters = self.session.scalars(
|
||||
select(SourceFilterDefinitionRecord).where(SourceFilterDefinitionRecord.source_category_id == category.id)
|
||||
).all()
|
||||
mappings = self.session.scalars(
|
||||
select(CriterionMappingRecord).where(CriterionMappingRecord.source_category_id == category.id)
|
||||
).all()
|
||||
return jsonable(
|
||||
{
|
||||
"source_category_status": category.taxonomy_status,
|
||||
"filters_discovered": len(filters),
|
||||
"filters_verified": sum(1 for row in mappings if row.status == MappingStatus.VERIFIED.value),
|
||||
"filters_unverified": sum(
|
||||
1 for row in mappings if row.status == MappingStatus.LEARNED_UNVERIFIED.value
|
||||
),
|
||||
"filters_broken": sum(1 for row in mappings if row.status == MappingStatus.BROKEN.value),
|
||||
"last_scan_at": category.last_taxonomy_scan_at,
|
||||
}
|
||||
)
|
||||
|
||||
def filters(self, source_id: str, category_key: str) -> dict[str, Any]:
|
||||
category = self._category(source_id, category_key)
|
||||
rows = self.session.scalars(
|
||||
@@ -207,7 +236,9 @@ class TaxonomyService:
|
||||
"name": category.name,
|
||||
"source_url": category.source_url,
|
||||
"canonical_category": category.canonical_category,
|
||||
"product_category_id": category.product_category_id,
|
||||
"status": category.status,
|
||||
"taxonomy_status": category.taxonomy_status,
|
||||
"last_verified_at": category.last_verified_at,
|
||||
"filters": filters,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user