applies minor fixes
This commit is contained in:
@@ -70,12 +70,7 @@ impl HistorySegment {
|
|||||||
let end = data.timestamps.partition_point(|x| x < &to);
|
let end = data.timestamps.partition_point(|x| x < &to);
|
||||||
|
|
||||||
if start < data.timestamps.len() {
|
if start < data.timestamps.len() {
|
||||||
let t = data.timestamps[start];
|
for i in start..end {
|
||||||
result.push(TelemetryDataItem {
|
|
||||||
value: data.values[start].clone(),
|
|
||||||
timestamp: t.to_rfc3339_opts(SecondsFormat::Millis, true),
|
|
||||||
});
|
|
||||||
for i in (start + 1)..end {
|
|
||||||
let t = data.timestamps[i];
|
let t = data.timestamps[i];
|
||||||
if t >= next_from {
|
if t >= next_from {
|
||||||
let time_since_next_from = t - next_from;
|
let time_since_next_from = t - next_from;
|
||||||
@@ -89,14 +84,11 @@ impl HistorySegment {
|
|||||||
let maximum_resolution_nanos = maximum_resolution_nanos as u64;
|
let maximum_resolution_nanos = maximum_resolution_nanos as u64;
|
||||||
let num_steps =
|
let num_steps =
|
||||||
nanos_since_next_from.div_ceil(maximum_resolution_nanos);
|
nanos_since_next_from.div_ceil(maximum_resolution_nanos);
|
||||||
let subsec_nanos = maximum_resolution.subsec_nanos() as u64;
|
if num_steps > i32::MAX as u64 {
|
||||||
// This will break once this can't be represented in 2^63 nanoseconds (over 200 years)
|
t + maximum_resolution
|
||||||
let seconds =
|
} else {
|
||||||
((maximum_resolution.num_seconds() as u64) * num_steps) as i64;
|
next_from + maximum_resolution * num_steps as i32
|
||||||
let nanos = (num_steps * subsec_nanos) as i64;
|
}
|
||||||
next_from
|
|
||||||
+ TimeDelta::seconds(seconds)
|
|
||||||
+ TimeDelta::nanoseconds(nanos)
|
|
||||||
}
|
}
|
||||||
_ => t + maximum_resolution, // If there is a gap so big it can't be represented in 2^63 nanoseconds (over 200 years) just skip forward
|
_ => t + maximum_resolution, // If there is a gap so big it can't be represented in 2^63 nanoseconds (over 200 years) just skip forward
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user