Code cleanup
This commit is contained in:
parent
766fd8ea7d
commit
7581ecf331
|
@ -15,7 +15,7 @@ use serde::{Deserialize, Deserializer, Serialize};
|
||||||
use ts_rs::TS;
|
use ts_rs::TS;
|
||||||
|
|
||||||
pub(crate) mod packed_time {
|
pub(crate) mod packed_time {
|
||||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::de::Error;
|
use serde::de::Error;
|
||||||
use serde::{Deserialize, Deserializer, Serializer};
|
use serde::{Deserialize, Deserializer, Serializer};
|
||||||
|
|
||||||
|
@ -30,15 +30,12 @@ pub(crate) mod packed_time {
|
||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
Ok(DateTime::<Utc>::from_naive_utc_and_offset(
|
DateTime::<Utc>::from_timestamp_millis(
|
||||||
NaiveDateTime::from_timestamp_millis(
|
String::deserialize(deserializer)?
|
||||||
String::deserialize(deserializer)?
|
.parse::<i64>()
|
||||||
.parse::<i64>()
|
.map_err(Error::custom)?,
|
||||||
.map_err(Error::custom)?,
|
)
|
||||||
)
|
.ok_or_else(|| Error::custom("millisecond value out of range"))
|
||||||
.ok_or_else(|| Error::custom("millisecond value out of range"))?,
|
|
||||||
Utc,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,14 +88,14 @@ impl SpanFilter {
|
||||||
pub fn start(&self) -> Option<(DateTime<Utc>, String)> {
|
pub fn start(&self) -> Option<(DateTime<Utc>, String)> {
|
||||||
match self {
|
match self {
|
||||||
Self::Start(StartFilter {
|
Self::Start(StartFilter {
|
||||||
time_start,
|
time_start,
|
||||||
id_start,
|
id_start,
|
||||||
})
|
})
|
||||||
| Self::Range(RangeFilter {
|
| Self::Range(RangeFilter {
|
||||||
time_start,
|
time_start,
|
||||||
id_start,
|
id_start,
|
||||||
..
|
..
|
||||||
}) => Some((*time_start, id_start.clone())),
|
}) => Some((*time_start, id_start.clone())),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,8 +104,8 @@ impl SpanFilter {
|
||||||
match self {
|
match self {
|
||||||
Self::End(EndFilter { time_end, id_end })
|
Self::End(EndFilter { time_end, id_end })
|
||||||
| Self::Range(RangeFilter {
|
| Self::Range(RangeFilter {
|
||||||
time_end, id_end, ..
|
time_end, id_end, ..
|
||||||
}) => Some((*time_end, id_end.clone())),
|
}) => Some((*time_end, id_end.clone())),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,10 +142,10 @@ impl SpanFilter {
|
||||||
})),
|
})),
|
||||||
Self::Range(RangeFilter { time_start, .. }) if *time_start > last_date => None,
|
Self::Range(RangeFilter { time_start, .. }) if *time_start > last_date => None,
|
||||||
Self::Range(RangeFilter {
|
Self::Range(RangeFilter {
|
||||||
time_start,
|
time_start,
|
||||||
id_start,
|
id_start,
|
||||||
..
|
..
|
||||||
}) => Some(SpanFilter::Range(RangeFilter {
|
}) => Some(SpanFilter::Range(RangeFilter {
|
||||||
time_start: *time_start,
|
time_start: *time_start,
|
||||||
id_start: id_start.clone(),
|
id_start: id_start.clone(),
|
||||||
time_end: last_date,
|
time_end: last_date,
|
||||||
|
|
Loading…
Reference in New Issue