feat: trace-level matching, health watcher/worker status, timezone config
This commit is contained in:
@@ -93,16 +93,15 @@ async fn create_identity(
|
||||
})?;
|
||||
|
||||
let id_table = crate::core::db::schema::table_name("identities");
|
||||
let name_col = if id_table.starts_with("dev.") { "name" } else { "real_name" };
|
||||
let query = format!(
|
||||
"SELECT uuid, reference_data->'total_references' as total,
|
||||
reference_data->'angles_covered' as angles,
|
||||
reference_data->'quality_avg' as quality
|
||||
FROM {}
|
||||
WHERE {} = $1
|
||||
WHERE name = $1
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 1",
|
||||
id_table, name_col
|
||||
id_table
|
||||
);
|
||||
|
||||
let row: Option<(String, Option<i32>, Option<Vec<String>>, Option<f64>)> =
|
||||
@@ -168,11 +167,19 @@ async fn list_identities(
|
||||
let id_table = crate::core::db::schema::table_name("identities");
|
||||
|
||||
let total: i64 = sqlx::query_scalar(&format!("SELECT COUNT(*) FROM {}", id_table))
|
||||
.fetch_one(db.pool()).await
|
||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, format!("Count error: {}", e)))?;
|
||||
.fetch_one(db.pool())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
format!("Count error: {}", e),
|
||||
)
|
||||
})?;
|
||||
|
||||
let name_col = if id_table.starts_with("dev.") { "name" } else { "real_name" };
|
||||
let sql = format!("SELECT id::int, uuid, {} AS name, metadata FROM {} ORDER BY id DESC LIMIT $1 OFFSET $2", name_col, id_table);
|
||||
let sql = format!(
|
||||
"SELECT id::int, uuid, name, metadata FROM {} ORDER BY id DESC LIMIT $1 OFFSET $2",
|
||||
id_table
|
||||
);
|
||||
|
||||
let rows: Vec<(i32, uuid::Uuid, String, Option<serde_json::Value>)> = match sqlx::query_as(&sql)
|
||||
.bind(page_size as i64)
|
||||
@@ -200,12 +207,25 @@ async fn list_identities(
|
||||
.collect();
|
||||
|
||||
let identities_table = crate::core::db::schema::table_name("identities");
|
||||
let total_identities: i64 = sqlx::query_scalar(&format!("SELECT COUNT(*) FROM {}", identities_table))
|
||||
.fetch_one(db.pool()).await.unwrap_or(0);
|
||||
let tmdb_identities: i64 = sqlx::query_scalar(&format!("SELECT COUNT(*) FROM {} WHERE source = 'tmdb'", identities_table))
|
||||
.fetch_one(db.pool()).await.unwrap_or(0);
|
||||
let auto_identities: i64 = sqlx::query_scalar(&format!("SELECT COUNT(*) FROM {} WHERE source = 'auto'", identities_table))
|
||||
.fetch_one(db.pool()).await.unwrap_or(0);
|
||||
let total_identities: i64 =
|
||||
sqlx::query_scalar(&format!("SELECT COUNT(*) FROM {}", identities_table))
|
||||
.fetch_one(db.pool())
|
||||
.await
|
||||
.unwrap_or(0);
|
||||
let tmdb_identities: i64 = sqlx::query_scalar(&format!(
|
||||
"SELECT COUNT(*) FROM {} WHERE source = 'tmdb'",
|
||||
identities_table
|
||||
))
|
||||
.fetch_one(db.pool())
|
||||
.await
|
||||
.unwrap_or(0);
|
||||
let auto_identities: i64 = sqlx::query_scalar(&format!(
|
||||
"SELECT COUNT(*) FROM {} WHERE source = 'auto'",
|
||||
identities_table
|
||||
))
|
||||
.fetch_one(db.pool())
|
||||
.await
|
||||
.unwrap_or(0);
|
||||
|
||||
Ok(Json(IdentityListResponse {
|
||||
identities,
|
||||
|
||||
Reference in New Issue
Block a user