mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +02:00
add some stats on the batches
This commit is contained in:
parent
229fa0f902
commit
4abcd9c04e
110 changed files with 688 additions and 323 deletions
|
@ -2,16 +2,17 @@ use serde::Serialize;
|
|||
use time::{Duration, OffsetDateTime};
|
||||
|
||||
use crate::{
|
||||
batches::{Batch, BatchId},
|
||||
batches::{Batch, BatchId, BatchStats},
|
||||
task_view::DetailsView,
|
||||
tasks::serialize_duration,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BatchView {
|
||||
pub uid: BatchId,
|
||||
pub details: DetailsView,
|
||||
pub stats: BatchStats,
|
||||
#[serde(serialize_with = "serialize_duration", default)]
|
||||
pub duration: Option<Duration>,
|
||||
#[serde(with = "time::serde::rfc3339", default)]
|
||||
|
@ -25,6 +26,7 @@ impl BatchView {
|
|||
Self {
|
||||
uid: batch.uid,
|
||||
details: batch.details.clone(),
|
||||
stats: batch.stats.clone(),
|
||||
duration: batch.finished_at.map(|finished_at| finished_at - batch.started_at),
|
||||
started_at: batch.started_at,
|
||||
finished_at: batch.finished_at,
|
||||
|
|
|
@ -1,22 +1,34 @@
|
|||
use std::collections::BTreeMap;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
use crate::task_view::DetailsView;
|
||||
use crate::{
|
||||
task_view::DetailsView,
|
||||
tasks::{Kind, Status},
|
||||
};
|
||||
|
||||
pub type BatchId = u32;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Batch {
|
||||
pub uid: BatchId,
|
||||
|
||||
pub details: DetailsView,
|
||||
pub stats: BatchStats,
|
||||
|
||||
#[serde(with = "time::serde::rfc3339")]
|
||||
pub started_at: OffsetDateTime,
|
||||
#[serde(with = "time::serde::rfc3339::option")]
|
||||
pub finished_at: Option<OffsetDateTime>,
|
||||
// pub details: Option<Details>,
|
||||
|
||||
// pub status: Status,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BatchStats {
|
||||
pub total_nb_tasks: BatchId,
|
||||
pub status: BTreeMap<Status, u32>,
|
||||
pub types: BTreeMap<Kind, u32>,
|
||||
pub index_uids: BTreeMap<String, u32>,
|
||||
}
|
||||
|
|
|
@ -363,7 +363,9 @@ impl From<&KindWithContent> for Option<Details> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Sequence)]
|
||||
#[derive(
|
||||
Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Sequence, PartialOrd, Ord,
|
||||
)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum Status {
|
||||
Enqueued,
|
||||
|
@ -422,7 +424,9 @@ impl fmt::Display for ParseTaskStatusError {
|
|||
}
|
||||
impl std::error::Error for ParseTaskStatusError {}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Sequence)]
|
||||
#[derive(
|
||||
Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Sequence, PartialOrd, Ord,
|
||||
)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum Kind {
|
||||
DocumentAdditionOrUpdate,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue