convert UpdateStatus to legacy meilisearch format

This commit is contained in:
Marin Postma 2021-04-29 19:31:58 +02:00 committed by marin postma
parent d46a2713d2
commit e8bd5ea4e0
No known key found for this signature in database
GPG key ID: 6088B7721C3E39F9
3 changed files with 231 additions and 6 deletions

View file

@ -84,6 +84,10 @@ impl Processed {
pub fn id(&self) -> u64 {
self.from.id()
}
pub fn meta(&self) -> &UpdateMeta {
self.from.meta()
}
}
#[derive(Debug, Serialize, Deserialize, Clone)]
@ -132,21 +136,29 @@ impl Aborted {
pub fn id(&self) -> u64 {
self.from.id()
}
pub fn meta(&self) -> &UpdateMeta {
self.from.meta()
}
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Failed {
#[serde(flatten)]
from: Processing,
error: UpdateError,
failed_at: DateTime<Utc>,
pub from: Processing,
pub error: UpdateError,
pub failed_at: DateTime<Utc>,
}
impl Failed {
pub fn id(&self) -> u64 {
self.from.id()
}
pub fn meta(&self) -> &UpdateMeta {
self.from.meta()
}
}
#[derive(Debug, Serialize, Deserialize, Clone)]
@ -170,6 +182,16 @@ impl UpdateStatus {
}
}
pub fn meta(&self) -> &UpdateMeta {
match self {
UpdateStatus::Processing(u) => u.meta(),
UpdateStatus::Enqueued(u) => u.meta(),
UpdateStatus::Processed(u) => u.meta(),
UpdateStatus::Aborted(u) => u.meta(),
UpdateStatus::Failed(u) => u.meta(),
}
}
pub fn processed(&self) -> Option<&Processed> {
match self {
UpdateStatus::Processed(p) => Some(p),