fix: /files total count from DB (was hardcoded 0)

This commit is contained in:
Accusys
2026-05-13 20:45:23 +08:00
parent 2e7dd44552
commit e6aa45d7ea
2 changed files with 10 additions and 1 deletions

View File

@@ -98,9 +98,11 @@ async fn list_files(
})
.collect();
let total = state.db.count_files().await.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
Ok(Json(FilesResponse {
success: true,
total: 0, // TODO: Implement count query
total,
page,
page_size,
data,

View File

@@ -2374,6 +2374,13 @@ impl PostgresDb {
Ok(rows)
}
pub async fn count_files(&self) -> Result<i64> {
let count: (i64,) = sqlx::query_as("SELECT COUNT(*) FROM videos")
.fetch_one(&self.pool)
.await?;
Ok(count.0)
}
pub async fn get_file_by_uuid(&self, uuid: &str) -> Result<Option<FileRecord>> {
let query = r#"
SELECT file_uuid, file_path, file_name, status, probe_json, created_at