update code level
This commit is contained in:
@@ -339,4 +339,30 @@ impl SearchDb {
|
||||
results.sort_by(|a, b| b.total_albums.cmp(&a.total_albums));
|
||||
results
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════
|
||||
// 元数据统计
|
||||
// ═══════════════════════════════════════
|
||||
|
||||
/// 获取全局统计信息
|
||||
pub async fn get_metadata_stats(&self) -> MetadataStats {
|
||||
let total_persons: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM persons")
|
||||
.fetch_one(&self.pool).await.unwrap_or(0);
|
||||
let total_aliases: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM person_aliases")
|
||||
.fetch_one(&self.pool).await.unwrap_or(0);
|
||||
let total_albums: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM albums")
|
||||
.fetch_one(&self.pool).await.unwrap_or(0);
|
||||
let total_images: i64 = sqlx::query_scalar("SELECT COALESCE(SUM(image_count), 0) FROM albums")
|
||||
.fetch_one(&self.pool).await.unwrap_or(0);
|
||||
let total_tags: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM album_tags")
|
||||
.fetch_one(&self.pool).await.unwrap_or(0);
|
||||
|
||||
MetadataStats {
|
||||
total_persons,
|
||||
total_aliases,
|
||||
total_albums,
|
||||
total_images,
|
||||
total_tags,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user