From 2fea1e8e69ac28b0d06e1d99b76a60d543dfc881 Mon Sep 17 00:00:00 2001 From: asonix Date: Tue, 18 Dec 2018 17:09:10 -0600 Subject: [PATCH] Tick before increment, tick on fetch --- jobs-core/src/storage.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jobs-core/src/storage.rs b/jobs-core/src/storage.rs index 3bd38a8..47ebb73 100644 --- a/jobs-core/src/storage.rs +++ b/jobs-core/src/storage.rs @@ -852,10 +852,13 @@ impl Stat { } fn inner_stat(self) -> JobStat { - match self { + let mut job_stat = match self { Stat::DeadJobs(job_stat) => job_stat, Stat::CompletedJobs(job_stat) => job_stat, - } + }; + + job_stat.tick(); + job_stat } fn dead_jobs() -> &'static str { @@ -898,12 +901,12 @@ impl JobStat { } fn increment(&mut self) { + self.tick(); + self.this_hour += 1; self.today += 1; self.this_month += 1; self.all_time += 1; - - self.tick(); } fn tick(&mut self) {