diff --git a/entities/src/state/mod.rs b/entities/src/state/mod.rs index 03c0e3b..8d8d9f2 100644 --- a/entities/src/state/mod.rs +++ b/entities/src/state/mod.rs @@ -66,4 +66,6 @@ pub struct CacheHost { /// Percentage of healthy checks since first seen pub healthy_percentage_overall: u8, pub connectivity: Option, + /// Internal: show last-seen information + pub __show_last_seen: bool, } diff --git a/scanner/src/cache_update.rs b/scanner/src/cache_update.rs index 7d9eb9b..9f4c6ea 100644 --- a/scanner/src/cache_update.rs +++ b/scanner/src/cache_update.rs @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only use std::collections::HashMap; -use chrono::TimeZone; +use chrono::{TimeZone, Duration}; use chrono::{Days, Utc}; use entities::host; use entities::prelude::*; @@ -137,8 +137,11 @@ impl Scanner { (!last_check.healthy) && self.inner.config.bad_hosts.contains(&host.domain); let host_ping_data = ping_data.remove(&host.id); + let last_healthy = last_healthy_check.remove(&host.id); + let __show_last_seen = last_healthy.map_or(true, |e|(time_now - e) > Duration::hours(4)); host_statistics.push(CacheHost { - last_healthy: last_healthy_check.remove(&host.id), + last_healthy: last_healthy, + __show_last_seen, url: host.url, domain: host.domain, points, diff --git a/server/templates/instances.html.j2 b/server/templates/instances.html.j2 index 074ab72..2731660 100644 --- a/server/templates/instances.html.j2 +++ b/server/templates/instances.html.j2 @@ -59,7 +59,7 @@ {%- set width = 110 -%} {%- set width_bar = 5 -%} {%- set offset = 5 -%} - {%- if host.recent_checks -%} + {%- if not host.__show_last_seen -%} {%- for check in host.recent_checks -%} {%- if check.1 -%}