From 0939e66c2da005bd8faa7039fbf77be0fdba2676 Mon Sep 17 00:00:00 2001 From: alemi Date: Sat, 5 Nov 2022 19:52:15 +0100 Subject: [PATCH] fix: refresh when changing db, don't load all points 1st time --- src/worker/visualizer.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/worker/visualizer.rs b/src/worker/visualizer.rs index 84f6ca8..6f897be 100644 --- a/src/worker/visualizer.rs +++ b/src/worker/visualizer.rs @@ -279,10 +279,11 @@ impl AppState { } // fetch new points + let lower_bound = std::cmp::max(self.last_check, now - new_width); let new_points = entities::points::Entity::find() .filter( Condition::all() - .add(entities::points::Column::X.gte(self.last_check as f64)) + .add(entities::points::Column::X.gte(lower_bound as f64)) .add(entities::points::Column::X.lte(now as f64)) ) .order_by(entities::points::Column::X, Order::Asc) @@ -332,6 +333,8 @@ impl AppState { Ok(new_db) => { info!("Connected to '{}'", uri); db = new_db; + self.last_check = 0; + self.last_refresh = 0; }, Err(e) => error!(target: "state-manager", "Could not connect to db: {:?}", e), };