From e6aa45d7ea33d1e5dfb48fcdaa5545dfca933d1e Mon Sep 17 00:00:00 2001 From: Accusys Date: Wed, 13 May 2026 20:45:23 +0800 Subject: [PATCH] fix: /files total count from DB (was hardcoded 0) --- src/api/identity_api.rs | 4 +++- src/core/db/postgres_db.rs | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/api/identity_api.rs b/src/api/identity_api.rs index 372e6f5..6cd163a 100644 --- a/src/api/identity_api.rs +++ b/src/api/identity_api.rs @@ -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, diff --git a/src/core/db/postgres_db.rs b/src/core/db/postgres_db.rs index 8f519f7..e024b57 100644 --- a/src/core/db/postgres_db.rs +++ b/src/core/db/postgres_db.rs @@ -2374,6 +2374,13 @@ impl PostgresDb { Ok(rows) } + pub async fn count_files(&self) -> Result { + 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> { let query = r#" SELECT file_uuid, file_path, file_name, status, probe_json, created_at