Expand Doris Kitchen import, failures, and tag curation
This commit is contained in:
@@ -58,7 +58,19 @@ class JsonRepository:
|
||||
current = self.list_suggestions()
|
||||
for idx, existing in enumerate(current):
|
||||
if existing.get("url") == item.get("url"):
|
||||
merged = {**existing, **item}
|
||||
merged = {**item}
|
||||
for key in (
|
||||
"status",
|
||||
"decision_at",
|
||||
"kitchenowl_status",
|
||||
"kitchenowl_result",
|
||||
):
|
||||
if existing.get(key) is not None:
|
||||
merged[key] = existing.get(key)
|
||||
if existing.get("id"):
|
||||
merged["id"] = existing["id"]
|
||||
if existing.get("created_at"):
|
||||
merged["created_at"] = existing["created_at"]
|
||||
current[idx] = merged
|
||||
self.store.save("suggestions", current)
|
||||
return merged
|
||||
@@ -83,5 +95,25 @@ class JsonRepository:
|
||||
items = sorted(self.list_suggestions(), key=lambda item: item.get("updated_at") or item.get("created_at") or "", reverse=True)
|
||||
return items[:limit]
|
||||
|
||||
def list_failed_searches(self) -> list[dict[str, Any]]:
|
||||
return self.store.load("failed_searches", [])
|
||||
|
||||
def log_failed_search(self, item: dict[str, Any]) -> dict[str, Any]:
|
||||
current = self.list_failed_searches()
|
||||
current.append(item)
|
||||
current = sorted(current, key=lambda entry: entry.get("created_at") or "", reverse=True)[:50]
|
||||
self.store.save("failed_searches", current)
|
||||
return item
|
||||
|
||||
def recent_failed_searches(self, limit: int = 12) -> list[dict[str, Any]]:
|
||||
return self.list_failed_searches()[:limit]
|
||||
|
||||
def update_failed_search(self, failed_search_id: str, updates: dict[str, Any]) -> dict[str, Any] | None:
|
||||
return self.store.update_collection_item(
|
||||
"failed_searches",
|
||||
lambda item: str(item.get("id")) == str(failed_search_id),
|
||||
lambda item: {**item, **updates},
|
||||
)
|
||||
|
||||
|
||||
repo = JsonRepository()
|
||||
|
||||
Reference in New Issue
Block a user