From e881a35fd4659d37eabb81c4bca72835252fdbae Mon Sep 17 00:00:00 2001 From: andymck Date: Tue, 18 Apr 2023 15:49:45 +0100 Subject: [PATCH] use offset to determine tx scaler recent activity (#463) --- iot_verifier/src/tx_scaler.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iot_verifier/src/tx_scaler.rs b/iot_verifier/src/tx_scaler.rs index b93ab9035..14cfe1f14 100644 --- a/iot_verifier/src/tx_scaler.rs +++ b/iot_verifier/src/tx_scaler.rs @@ -23,6 +23,7 @@ pub struct Server { hex_density_map: SharedHexDensityMap, pool: PgPool, trigger_interval: Duration, + refresh_offset: Duration, } #[derive(Debug, thiserror::Error)] @@ -46,6 +47,7 @@ impl Server { hex_density_map: SharedHexDensityMap::new(), pool, trigger_interval: Duration::seconds(settings.transmit_scale_interval), + refresh_offset: settings.loader_window_max_lookback_age(), }; server.refresh_scaling_map().await?; @@ -80,7 +82,7 @@ impl Server { } pub async fn refresh_scaling_map(&mut self) -> Result<(), TxScalerError> { - let refresh_start = Utc::now(); + let refresh_start = Utc::now() - self.refresh_offset; tracing::info!("density_scaler: generating hex scaling map, starting at {refresh_start:?}"); let mut global_map = GlobalHexMap::new(); let active_gateways = self