statserv: persist per-channel activity across restart too
All checks were successful
CI / check (push) Successful in 3m49s
All checks were successful
CI / check (push) Successful in 3m49s
The earlier StatsSet fix persisted only the shared namespaced counters. The per-channel BOTSTATS view (lines seen + top talkers, from /statserv #chan) lived on the LiveChannel struct, which is rebuilt from each burst — so it reset to zero on restart. Move it to a name-keyed Network.chan_activity map (independent of live membership, seedable before the burst) and carry it in the StatsSet snapshot (new serde-default `channels` field) alongside the counters. Reworded the notice from 'seen this session' now that it persists.
This commit is contained in:
parent
8a9b6a37ca
commit
1f6a11dba2
8 changed files with 91 additions and 26 deletions
|
|
@ -213,8 +213,9 @@ impl Engine {
|
|||
(!topics.is_empty()).then(|| (s.nick().to_string(), blurb, topics))
|
||||
})
|
||||
.collect();
|
||||
// Restore the persisted stat counters so they survive a restart.
|
||||
// Restore persisted stats so they survive a restart.
|
||||
network.seed_stats(db.persisted_stats());
|
||||
network.seed_chan_activity(db.persisted_chan_stats());
|
||||
Self {
|
||||
services,
|
||||
network,
|
||||
|
|
@ -275,10 +276,11 @@ impl Engine {
|
|||
// Only the real counters are persisted; the live gauges above are re-derived.
|
||||
pub fn persist_stats(&mut self) {
|
||||
let counters = self.network.stat_counters().clone();
|
||||
if counters.is_empty() {
|
||||
let chan_stats = self.network.chan_activity_snapshot();
|
||||
if counters.is_empty() && chan_stats.is_empty() {
|
||||
return;
|
||||
}
|
||||
if let Err(err) = self.db.persist_stats(&counters) {
|
||||
if let Err(err) = self.db.persist_stats(&counters, chan_stats) {
|
||||
tracing::warn!(%err, "failed to persist stat counters");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue