fix: /files total count from DB (was hardcoded 0)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user