This commit is contained in:
lasta
2026-05-11 22:55:01 +09:00
parent 3663734781
commit 0f34a451fc
10 changed files with 634 additions and 29 deletions

View File

@@ -82,6 +82,30 @@ class KnowledgeRepository:
raise KeyError(f"Source not found: {source_name}")
return source
def reset_project_runtime_data(self, project_id: int) -> dict[str, int]:
delete_order = [
models.FeedbackLog,
models.UserPreference,
models.UserProfile,
models.CrawlJob,
models.ExtractionLog,
models.Evidence,
models.Relation,
models.Claim,
models.Attribute,
models.Page,
models.Entity,
]
deleted: dict[str, int] = {}
for table_model in delete_order:
count = (
self.session.query(table_model)
.filter(table_model.project_id == project_id)
.delete(synchronize_session=False)
)
deleted[table_model.__tablename__] = int(count or 0)
return deleted
def upsert_page(
self,
project_id: int,