Added rayon
This commit is contained in:
parent
0b9487bde5
commit
63496cfc93
3 changed files with 816 additions and 119 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use crate::core::models::{UnifiedData, UnifiedGroupData};
|
||||
use crate::data::heartbeat::model::HeartbeatEntry;
|
||||
use crate::i18n::t;
|
||||
use rayon::prelude::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum MonitorStatus {
|
||||
|
|
@ -93,8 +94,8 @@ fn get_status_history(heartbeats: &[HeartbeatEntry]) -> Vec<MonitorStatus> {
|
|||
|
||||
fn add_monitor_view_state(group: UnifiedGroupData) -> Vec<MonitorViewState> {
|
||||
let mut monitors = Vec::with_capacity(group.monitors.len());
|
||||
group.monitors.into_par_iter().map(|monitor| {
|
||||
|
||||
for monitor in group.monitors {
|
||||
let status_history = get_status_history(&monitor.heartbeats);
|
||||
|
||||
let status = match monitor.heartbeats.last().map(|h| h.status) {
|
||||
|
|
@ -115,14 +116,14 @@ fn add_monitor_view_state(group: UnifiedGroupData) -> Vec<MonitorViewState> {
|
|||
.map(|u| u.get_perc_formated())
|
||||
.unwrap_or_else(|| t("unknown").to_string());
|
||||
|
||||
monitors.push(MonitorViewState {
|
||||
MonitorViewState {
|
||||
name: monitor.name,
|
||||
status,
|
||||
response_time,
|
||||
uptime_24h,
|
||||
status_history,
|
||||
});
|
||||
}
|
||||
}
|
||||
}).collect_into_vec(&mut monitors);
|
||||
|
||||
monitors.sort_by_key(|m| m.name.clone());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue