From 89ba24c86bbe8895017833fba7b6b8b43f0a62d5 Mon Sep 17 00:00:00 2001 From: SJ Date: Fri, 25 Apr 2014 13:42:08 +0200 Subject: [PATCH] health stat fix --- webui/controller/health/worker.php | 4 ++-- webui/model/health/health.php | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/webui/controller/health/worker.php b/webui/controller/health/worker.php index 5afa0f23..8932aa00 100644 --- a/webui/controller/health/worker.php +++ b/webui/controller/health/worker.php @@ -66,8 +66,8 @@ class ControllerHealthWorker extends Controller { list($archivesizeraw, $this->data['counters']) = $this->model_stat_counter->get_counters(); $oldest_record_timestamp = $this->model_health_health->get_oldest_record_ts(); - $total_number_days = round( (time() - $oldest_record_timestamp) / 86400 ); - + $total_number_days = round( (time() - $this->model_health_health->get_first_email_arrival_ts()) / 86400 ); + $this->data['archive_size'] = nice_size($archivesizeraw, ' '); $this->data['prefix'] = ''; diff --git a/webui/model/health/health.php b/webui/model/health/health.php index 9cf28f76..5ee5f12d 100644 --- a/webui/model/health/health.php +++ b/webui/model/health/health.php @@ -181,6 +181,15 @@ class ModelHealthHealth extends Model { } + public function get_first_email_arrival_ts() { + $query = $this->db->query("SELECT `arrived` FROM " . TABLE_META . " ORDER BY id ASC LIMIT 1"); + + if(isset($query->row)) { return $query->row['arrived']; } + + return time(); + } + + public function get_sphinx_size($directory = DIR_SPHINX) { $dirSize=0;