v0.14.0
This commit is contained in:
@@ -25,6 +25,27 @@ pub fn start(state: AppState) {
|
||||
tracing::warn!(error=?err, "cannot reset temporary thermostat observation continuity after restart");
|
||||
}
|
||||
|
||||
let cloud_reconnect_provider = state.providers.cloud().clone();
|
||||
let cloud_reconnect_settings = state.settings.clone();
|
||||
let cloud_reconnect_db = state.db.clone();
|
||||
tokio::spawn(async move {
|
||||
crate::provider::cloud_reconnect_loop(
|
||||
cloud_reconnect_provider,
|
||||
cloud_reconnect_settings,
|
||||
cloud_reconnect_db,
|
||||
)
|
||||
.await;
|
||||
});
|
||||
let cloud_push_state = state.clone();
|
||||
tokio::spawn(async move {
|
||||
cloud_push_loop(cloud_push_state).await;
|
||||
});
|
||||
|
||||
let ha_energy_state = state.clone();
|
||||
tokio::spawn(async move {
|
||||
home_assistant_energy_loop(ha_energy_state).await;
|
||||
});
|
||||
|
||||
let control_plan_state = state.clone();
|
||||
tokio::spawn(async move {
|
||||
control_plan_cache_loop(control_plan_state).await;
|
||||
@@ -144,6 +165,13 @@ pub fn start(state: AppState) {
|
||||
Ok(_) => {}
|
||||
Err(err) => tracing::warn!(error=?err, "cannot prune readings"),
|
||||
}
|
||||
match maintenance_state.db.prune_energy_readings(retention_days) {
|
||||
Ok(count) if count > 0 => {
|
||||
tracing::info!(count, retention_days, "old energy readings pruned")
|
||||
}
|
||||
Ok(_) => {}
|
||||
Err(err) => tracing::warn!(error=?err, "cannot prune energy readings"),
|
||||
}
|
||||
}
|
||||
let event_retention_days = settings.event_log_retention_days.max(1) as i64;
|
||||
match maintenance_state.db.prune_events(event_retention_days) {
|
||||
@@ -176,5 +204,17 @@ async fn archive_old_history(state: &AppState, threshold_days: u32) -> Result<u6
|
||||
break;
|
||||
}
|
||||
}
|
||||
for _ in 0..50 {
|
||||
let energy = state.db.energy_before(cutoff, 1_000)?;
|
||||
if energy.is_empty() {
|
||||
break;
|
||||
}
|
||||
influxdb::write_energy_batch(&state.http, &settings, &energy).await?;
|
||||
let deleted = state.db.delete_energy_batch(&energy)?;
|
||||
moved += deleted;
|
||||
if deleted == 0 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Ok(moved)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user