feat: add cache toggle, unregister API and chunk training docs

- Add POST /api/v1/config/cache for cache toggle
- Add POST /api/v1/unregister for video deletion
- Add CHUNK_DATA_STRUCTURE.md for marcom training
- Fix processor_results query in delete_video
This commit is contained in:
Warren
2026-03-25 15:44:47 +08:00
parent de80b96c15
commit e4d3365ada
4 changed files with 409 additions and 0 deletions

View File

@@ -584,6 +584,40 @@ impl PostgresDb {
Ok(())
}
pub async fn delete_video(&self, uuid: &str) -> Result<()> {
tracing::info!("[PostgresDb] Deleting video: {}", uuid);
let tx = self.pool.begin().await?;
sqlx::query("DELETE FROM chunk_vectors WHERE uuid = $1")
.bind(uuid)
.execute(&self.pool)
.await?;
sqlx::query("DELETE FROM chunks WHERE uuid = $1")
.bind(uuid)
.execute(&self.pool)
.await?;
sqlx::query("DELETE FROM processor_results WHERE video_id IN (SELECT id FROM videos WHERE uuid = $1)")
.bind(uuid)
.execute(&self.pool)
.await?;
sqlx::query("DELETE FROM videos WHERE uuid = $1")
.bind(uuid)
.execute(&self.pool)
.await?;
tx.commit().await?;
let mut cache = self.cache.write().await;
cache.videos.remove(uuid);
tracing::info!("[PostgresDb] Video deleted: {}", uuid);
Ok(())
}
pub async fn get_storage_status(&self, uuid: &str) -> Result<Option<StorageStatus>> {
if let Some(video) = self.get_video_by_uuid(uuid).await? {
Ok(Some(video.storage))