From c2b58720d1086cdb848f268cad023cc83fc6db03 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Tue, 1 Mar 2022 19:02:32 +0100 Subject: [PATCH] Fix(dumps): Explicitly define serde for time --- meilisearch-http/src/routes/mod.rs | 12 ++++++------ .../src/index_controller/dump_actor/compat/v2.rs | 5 +++++ .../src/index_controller/dump_actor/compat/v3.rs | 4 ++++ .../src/index_controller/dump_actor/mod.rs | 1 + meilisearch-lib/src/tasks/task.rs | 15 +++++++++++++-- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/meilisearch-http/src/routes/mod.rs b/meilisearch-http/src/routes/mod.rs index 4b9fab978..49397444f 100644 --- a/meilisearch-http/src/routes/mod.rs +++ b/meilisearch-http/src/routes/mod.rs @@ -54,9 +54,9 @@ pub struct ProcessedUpdateResult { #[serde(rename = "type")] pub update_type: UpdateType, pub duration: f64, // in seconds - #[serde(serialize_with = "time::serde::rfc3339::serialize")] + #[serde(with = "time::serde::rfc3339")] pub enqueued_at: OffsetDateTime, - #[serde(serialize_with = "time::serde::rfc3339::serialize")] + #[serde(with = "time::serde::rfc3339")] pub processed_at: OffsetDateTime, } @@ -68,9 +68,9 @@ pub struct FailedUpdateResult { pub update_type: UpdateType, pub error: ResponseError, pub duration: f64, // in seconds - #[serde(serialize_with = "time::serde::rfc3339::serialize")] + #[serde(with = "time::serde::rfc3339")] pub enqueued_at: OffsetDateTime, - #[serde(serialize_with = "time::serde::rfc3339::serialize")] + #[serde(with = "time::serde::rfc3339")] pub processed_at: OffsetDateTime, } @@ -80,11 +80,11 @@ pub struct EnqueuedUpdateResult { pub update_id: u64, #[serde(rename = "type")] pub update_type: UpdateType, - #[serde(serialize_with = "time::serde::rfc3339::serialize")] + #[serde(with = "time::serde::rfc3339")] pub enqueued_at: OffsetDateTime, #[serde( skip_serializing_if = "Option::is_none", - serialize_with = "time::serde::rfc3339::option::serialize" + with = "time::serde::rfc3339::option" )] pub started_processing_at: Option, } diff --git a/meilisearch-lib/src/index_controller/dump_actor/compat/v2.rs b/meilisearch-lib/src/index_controller/dump_actor/compat/v2.rs index d7ba41479..a30e24794 100644 --- a/meilisearch-lib/src/index_controller/dump_actor/compat/v2.rs +++ b/meilisearch-lib/src/index_controller/dump_actor/compat/v2.rs @@ -51,6 +51,7 @@ pub enum UpdateMeta { pub struct Enqueued { pub update_id: u64, pub meta: UpdateMeta, + #[serde(with = "time::serde::rfc3339")] pub enqueued_at: OffsetDateTime, pub content: Option, } @@ -59,6 +60,7 @@ pub struct Enqueued { #[serde(rename_all = "camelCase")] pub struct Processed { pub success: UpdateResult, + #[serde(with = "time::serde::rfc3339")] pub processed_at: OffsetDateTime, #[serde(flatten)] pub from: Processing, @@ -69,6 +71,7 @@ pub struct Processed { pub struct Processing { #[serde(flatten)] pub from: Enqueued, + #[serde(with = "time::serde::rfc3339")] pub started_processing_at: OffsetDateTime, } @@ -77,6 +80,7 @@ pub struct Processing { pub struct Aborted { #[serde(flatten)] pub from: Enqueued, + #[serde(with = "time::serde::rfc3339")] pub aborted_at: OffsetDateTime, } @@ -86,6 +90,7 @@ pub struct Failed { #[serde(flatten)] pub from: Processing, pub error: ResponseError, + #[serde(with = "time::serde::rfc3339")] pub failed_at: OffsetDateTime, } diff --git a/meilisearch-lib/src/index_controller/dump_actor/compat/v3.rs b/meilisearch-lib/src/index_controller/dump_actor/compat/v3.rs index 1e378805d..7cd670bad 100644 --- a/meilisearch-lib/src/index_controller/dump_actor/compat/v3.rs +++ b/meilisearch-lib/src/index_controller/dump_actor/compat/v3.rs @@ -107,6 +107,7 @@ pub enum UpdateMeta { pub struct Enqueued { pub update_id: u64, pub meta: Update, + #[serde(with = "time::serde::rfc3339")] pub enqueued_at: OffsetDateTime, } @@ -122,6 +123,7 @@ impl Enqueued { #[serde(rename_all = "camelCase")] pub struct Processed { pub success: v2::UpdateResult, + #[serde(with = "time::serde::rfc3339")] pub processed_at: OffsetDateTime, #[serde(flatten)] pub from: Processing, @@ -144,6 +146,7 @@ impl Processed { pub struct Processing { #[serde(flatten)] pub from: Enqueued, + #[serde(with = "time::serde::rfc3339")] pub started_processing_at: OffsetDateTime, } @@ -163,6 +166,7 @@ pub struct Failed { pub from: Processing, pub msg: String, pub code: Code, + #[serde(with = "time::serde::rfc3339")] pub failed_at: OffsetDateTime, } diff --git a/meilisearch-lib/src/index_controller/dump_actor/mod.rs b/meilisearch-lib/src/index_controller/dump_actor/mod.rs index d9ff63f2c..16e328e3b 100644 --- a/meilisearch-lib/src/index_controller/dump_actor/mod.rs +++ b/meilisearch-lib/src/index_controller/dump_actor/mod.rs @@ -40,6 +40,7 @@ pub struct Metadata { db_version: String, index_db_size: usize, update_db_size: usize, + #[serde(with = "time::serde::rfc3339")] dump_date: OffsetDateTime, } diff --git a/meilisearch-lib/src/tasks/task.rs b/meilisearch-lib/src/tasks/task.rs index 1c67fafa8..ecbd4ca62 100644 --- a/meilisearch-lib/src/tasks/task.rs +++ b/meilisearch-lib/src/tasks/task.rs @@ -36,21 +36,32 @@ impl From for TaskResult { #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] #[cfg_attr(test, derive(proptest_derive::Arbitrary))] pub enum TaskEvent { - Created(#[cfg_attr(test, proptest(strategy = "test::datetime_strategy()"))] OffsetDateTime), + Created( + #[cfg_attr(test, proptest(strategy = "test::datetime_strategy()"))] + #[serde(with = "time::serde::rfc3339")] + OffsetDateTime, + ), Batched { #[cfg_attr(test, proptest(strategy = "test::datetime_strategy()"))] + #[serde(with = "time::serde::rfc3339")] timestamp: OffsetDateTime, batch_id: BatchId, }, - Processing(#[cfg_attr(test, proptest(strategy = "test::datetime_strategy()"))] OffsetDateTime), + Processing( + #[cfg_attr(test, proptest(strategy = "test::datetime_strategy()"))] + #[serde(with = "time::serde::rfc3339")] + OffsetDateTime, + ), Succeded { result: TaskResult, #[cfg_attr(test, proptest(strategy = "test::datetime_strategy()"))] + #[serde(with = "time::serde::rfc3339")] timestamp: OffsetDateTime, }, Failed { error: ResponseError, #[cfg_attr(test, proptest(strategy = "test::datetime_strategy()"))] + #[serde(with = "time::serde::rfc3339")] timestamp: OffsetDateTime, }, }