fix: file/identities — replace NULL first/last_appearance with actual start_frame/end_frame + start_time/end_time + fps
This commit is contained in:
@@ -170,6 +170,7 @@ async fn get_file_detail(
|
||||
pub struct FileIdentitiesResponse {
|
||||
pub success: bool,
|
||||
pub file_uuid: String,
|
||||
pub fps: f64,
|
||||
pub total: i64,
|
||||
pub page: usize,
|
||||
pub page_size: usize,
|
||||
@@ -183,8 +184,10 @@ pub struct FileIdentityItem {
|
||||
pub metadata: serde_json::Value,
|
||||
pub face_count: Option<i32>,
|
||||
pub speaker_count: Option<i32>,
|
||||
pub first_appearance: Option<f64>,
|
||||
pub last_appearance: Option<f64>,
|
||||
pub start_frame: Option<i32>,
|
||||
pub end_frame: Option<i32>,
|
||||
pub start_time: Option<f64>,
|
||||
pub end_time: Option<f64>,
|
||||
pub confidence: Option<f64>,
|
||||
}
|
||||
|
||||
@@ -203,6 +206,7 @@ async fn get_file_identities(
|
||||
.await
|
||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
|
||||
|
||||
let fps = records.first().map(|r| r.fps).unwrap_or(25.0);
|
||||
let data: Vec<FileIdentityItem> = records
|
||||
.into_iter()
|
||||
.map(|r| FileIdentityItem {
|
||||
@@ -211,8 +215,10 @@ async fn get_file_identities(
|
||||
metadata: r.metadata,
|
||||
face_count: r.face_count,
|
||||
speaker_count: r.speaker_count,
|
||||
first_appearance: r.first_appearance,
|
||||
last_appearance: r.last_appearance,
|
||||
start_frame: r.start_frame,
|
||||
end_frame: r.end_frame,
|
||||
start_time: r.start_frame.map(|sf| sf as f64 / r.fps),
|
||||
end_time: r.end_frame.map(|ef| ef as f64 / r.fps),
|
||||
confidence: r.confidence,
|
||||
})
|
||||
.collect();
|
||||
@@ -220,6 +226,7 @@ async fn get_file_identities(
|
||||
Ok(Json(FileIdentitiesResponse {
|
||||
success: true,
|
||||
file_uuid: file_uuid,
|
||||
fps,
|
||||
total: data.len() as i64,
|
||||
page,
|
||||
page_size,
|
||||
|
||||
Reference in New Issue
Block a user