test
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user