mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 12:54:26 +01:00
fix the update from v1_9 to v1_10 by providing a custom datetime formatter myself
This commit is contained in:
parent
5f57306858
commit
4eef0cd332
@ -58,8 +58,8 @@ impl From<v1_9::IndexStats> for IndexStats {
|
||||
database_size,
|
||||
used_database_size,
|
||||
field_distribution,
|
||||
created_at,
|
||||
updated_at,
|
||||
created_at: created_at.0,
|
||||
updated_at: updated_at.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,6 +76,13 @@ fn update_index_stats(
|
||||
) -> anyhow::Result<()> {
|
||||
let ctx = || format!("while updating index stats for index `{index_uid}`");
|
||||
|
||||
let stats: Option<&str> = index_stats
|
||||
.remap_data_type::<Str>()
|
||||
.get(sched_wtxn, &index_uuid)
|
||||
.with_context(ctx)
|
||||
.with_context(|| "While reading value")?;
|
||||
dbg!(stats);
|
||||
|
||||
let stats: Option<v1_9::IndexStats> = index_stats
|
||||
.remap_data_type::<SerdeJson<v1_9::IndexStats>>()
|
||||
.get(sched_wtxn, &index_uuid)
|
||||
@ -139,13 +146,13 @@ fn date_round_trip(
|
||||
key: &str,
|
||||
) -> anyhow::Result<()> {
|
||||
let datetime =
|
||||
db.remap_types::<Str, SerdeJson<v1_9::OffsetDateTime>>().get(wtxn, key).with_context(
|
||||
|| format!("could not read `{key}` while updating date format for index `{index_uid}`"),
|
||||
)?;
|
||||
db.remap_types::<Str, SerdeJson<v1_9::LegacyTime>>().get(wtxn, key).with_context(|| {
|
||||
format!("could not read `{key}` while updating date format for index `{index_uid}`")
|
||||
})?;
|
||||
|
||||
if let Some(datetime) = datetime {
|
||||
db.remap_types::<Str, SerdeJson<self::OffsetDateTime>>()
|
||||
.put(wtxn, key, &self::OffsetDateTime(datetime))
|
||||
.put(wtxn, key, &self::OffsetDateTime(datetime.0))
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"could not write `{key}` while updating date format for index `{index_uid}`"
|
||||
|
@ -1,4 +1,5 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
pub type FieldDistribution = std::collections::BTreeMap<String, u64>;
|
||||
|
||||
@ -21,9 +22,9 @@ pub struct IndexStats {
|
||||
/// Association of every field name with the number of times it occurs in the documents.
|
||||
pub field_distribution: FieldDistribution,
|
||||
/// Creation date of the index.
|
||||
pub created_at: time::OffsetDateTime,
|
||||
pub created_at: LegacyTime,
|
||||
/// Date of the last update of the index.
|
||||
pub updated_at: time::OffsetDateTime,
|
||||
pub updated_at: LegacyTime,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
@ -97,4 +98,9 @@ mod rest {
|
||||
}
|
||||
}
|
||||
|
||||
pub type OffsetDateTime = time::OffsetDateTime;
|
||||
// 2024-11-04 13:32:08.48368 +00:00:00
|
||||
time::serde::format_description!(legacy_datetime, OffsetDateTime, "[year]-[month]-[day] [hour]:[minute]:[second].[subsecond] [offset_hour sign:mandatory]:[offset_minute]:[offset_second]");
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct LegacyTime(#[serde(with = "legacy_datetime")] pub OffsetDateTime);
|
||||
|
Loading…
Reference in New Issue
Block a user