optimizations
This commit is contained in:
parent
64f5115d54
commit
99d4b94e5c
6 changed files with 54 additions and 48 deletions
|
|
@ -95,16 +95,12 @@ impl DashboardViewState {
|
|||
}
|
||||
|
||||
fn get_status_history(heartbeats: &[HeartbeatEntry]) -> Vec<MonitorStatus> {
|
||||
let mut history = heartbeats
|
||||
.iter()
|
||||
.rev()
|
||||
.take(100)
|
||||
.map(|h| match h.status {
|
||||
0 => MonitorStatus::Down,
|
||||
1 => MonitorStatus::Up,
|
||||
_ => MonitorStatus::Unknown,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let mut history: Vec<_> = Vec::with_capacity(heartbeats.len());
|
||||
history.extend(heartbeats.iter().rev().take(100).map(|h| match h.status {
|
||||
0 => MonitorStatus::Down,
|
||||
1 => MonitorStatus::Up,
|
||||
_ => MonitorStatus::Unknown,
|
||||
}));
|
||||
|
||||
while history.len() < 100 {
|
||||
history.push(MonitorStatus::Unknown);
|
||||
|
|
@ -142,7 +138,7 @@ fn add_monitor_view_state(group: UnifiedGroupData) -> Vec<MonitorViewState> {
|
|||
|
||||
let name: Cow<'static, str> = match monitor.name {
|
||||
Cow::Borrowed(borrowed) => Cow::Owned(borrowed.to_string()),
|
||||
Cow::Owned(owned) => Cow::Owned(owned)
|
||||
Cow::Owned(owned) => Cow::Owned(owned),
|
||||
};
|
||||
|
||||
MonitorViewState {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue