Rename fields

This commit is contained in:
Mubelotix 2025-06-26 12:30:08 +02:00
parent 4d26e9c6f2
commit 44d6430bae
No known key found for this signature in database
GPG key ID: 0406DF6C3A69B942
3 changed files with 11 additions and 11 deletions

View file

@ -32,7 +32,7 @@ pub struct BatchStatsView {
#[serde(flatten)]
pub stats: BatchStats,
#[serde(skip_serializing_if = "EmbedderStatsView::skip_serializing", default)]
pub embedder: EmbedderStatsView,
pub embedder_requests: EmbedderStatsView,
}
impl BatchView {
@ -43,7 +43,7 @@ impl BatchView {
details: batch.details.clone(),
stats: BatchStatsView {
stats: batch.stats.clone(),
embedder: batch.embedder_stats.clone(),
embedder_requests: batch.embedder_stats.clone(),
},
duration: batch.finished_at.map(|finished_at| finished_at - batch.started_at),
started_at: batch.started_at,

View file

@ -92,8 +92,8 @@ pub struct BatchStats {
#[serde(rename_all = "camelCase")]
#[schema(rename_all = "camelCase")]
pub struct EmbedderStatsView {
pub total_count: usize,
pub error_count: usize,
pub total: usize,
pub failed: usize,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub last_error: Option<String>,
}
@ -102,8 +102,8 @@ impl From<&EmbedderStats> for EmbedderStatsView {
fn from(stats: &EmbedderStats) -> Self {
let errors = stats.errors.read().unwrap_or_else(|p| p.into_inner());
Self {
total_count: stats.total_count.load(std::sync::atomic::Ordering::Relaxed),
error_count: errors.1 as usize,
total: stats.total_count.load(std::sync::atomic::Ordering::Relaxed),
failed: errors.1 as usize,
last_error: errors.0.clone(),
}
}
@ -111,6 +111,6 @@ impl From<&EmbedderStats> for EmbedderStatsView {
impl EmbedderStatsView {
pub fn skip_serializing(&self) -> bool {
self.total_count == 0 && self.error_count == 0 && self.last_error.is_none()
self.total == 0 && self.failed == 0 && self.last_error.is_none()
}
}