Implements the get all batches route with filters working

This commit is contained in:
Tamo 2024-11-14 17:31:02 +01:00
parent 6062914654
commit a1251c3c83
No known key found for this signature in database
GPG key ID: 20CD8020AFA88D69
179 changed files with 5362 additions and 849 deletions

View file

@ -0,0 +1,30 @@
use serde::Serialize;
use time::{Duration, OffsetDateTime};
use crate::{
batches::{Batch, BatchId},
tasks::serialize_duration,
};
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BatchView {
pub uid: BatchId,
#[serde(serialize_with = "serialize_duration", default)]
pub duration: Option<Duration>,
#[serde(with = "time::serde::rfc3339", default)]
pub started_at: OffsetDateTime,
#[serde(with = "time::serde::rfc3339::option", default)]
pub finished_at: Option<OffsetDateTime>,
}
impl BatchView {
pub fn from_batch(batch: &Batch) -> Self {
Self {
uid: batch.uid,
duration: batch.finished_at.map(|finished_at| finished_at - batch.started_at),
started_at: batch.started_at,
finished_at: batch.finished_at,
}
}
}

View file

@ -344,6 +344,7 @@ NoSpaceLeftOnDevice , System , UNPROCESSABLE_ENT
PayloadTooLarge , InvalidRequest , PAYLOAD_TOO_LARGE ;
TooManySearchRequests , System , SERVICE_UNAVAILABLE ;
TaskNotFound , InvalidRequest , NOT_FOUND ;
BatchNotFound , InvalidRequest , NOT_FOUND ;
TooManyOpenFiles , System , UNPROCESSABLE_ENTITY ;
TooManyVectors , InvalidRequest , BAD_REQUEST ;
UnretrievableDocument , Internal , BAD_REQUEST ;

View file

@ -1,3 +1,4 @@
pub mod batch_view;
pub mod batches;
pub mod compression;
pub mod deserr;