fix: excessive logging and records overlapping

This commit is contained in:
əlemi 2022-11-05 18:34:50 +01:00
parent 08ed95d74c
commit ddf237861c
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 3 additions and 9 deletions

View file

@ -46,7 +46,6 @@ pub async fn surveyor_loop(
continue;
}
}
info!(target: "surveyor", "Reloaded sources and metrics");
last_fetch = Utc::now().timestamp();
}

View file

@ -252,8 +252,7 @@ impl AppState {
if let Err(e) = self.tx.points.send(self.points.clone().into()) {
warn!(target: "state-manager", "Could not send new points: {:?}", e); // TODO should be an err?
}
self.last_check = Utc::now().timestamp() - *self.width.borrow();
info!(target: "state-manager", "Reloaded points");
self.last_check = now;
Ok(())
}
@ -264,19 +263,15 @@ impl AppState {
// fetch previous points
if new_width != self.last_width {
let mut previous_points = entities::points::Entity::find()
let previous_points = entities::points::Entity::find()
.filter(
Condition::all()
.add(entities::points::Column::X.gte(now - new_width))
.add(entities::points::Column::X.lte(now - self.last_width))
)
.order_by(entities::points::Column::X, Order::Asc)
.order_by(entities::points::Column::X, Order::Desc)
.all(db)
.await?;
if previous_points.len() > 0 {
info!(target: "state-manager", "Fetched {} previous points", previous_points.len());
}
previous_points.reverse(); // TODO wasteful!
for p in previous_points {
self.points.push_front(p);
changes = true;