applies minor fixes
This commit is contained in:
@@ -70,12 +70,7 @@ impl HistorySegment {
|
||||
let end = data.timestamps.partition_point(|x| x < &to);
|
||||
|
||||
if start < data.timestamps.len() {
|
||||
let t = data.timestamps[start];
|
||||
result.push(TelemetryDataItem {
|
||||
value: data.values[start].clone(),
|
||||
timestamp: t.to_rfc3339_opts(SecondsFormat::Millis, true),
|
||||
});
|
||||
for i in (start + 1)..end {
|
||||
for i in start..end {
|
||||
let t = data.timestamps[i];
|
||||
if 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 num_steps =
|
||||
nanos_since_next_from.div_ceil(maximum_resolution_nanos);
|
||||
let subsec_nanos = maximum_resolution.subsec_nanos() as u64;
|
||||
// This will break once this can't be represented in 2^63 nanoseconds (over 200 years)
|
||||
let seconds =
|
||||
((maximum_resolution.num_seconds() as u64) * num_steps) as i64;
|
||||
let nanos = (num_steps * subsec_nanos) as i64;
|
||||
next_from
|
||||
+ TimeDelta::seconds(seconds)
|
||||
+ TimeDelta::nanoseconds(nanos)
|
||||
if num_steps > i32::MAX as u64 {
|
||||
t + maximum_resolution
|
||||
} else {
|
||||
next_from + maximum_resolution * num_steps as i32
|
||||
}
|
||||
}
|
||||
_ => 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