From 447ea6c47ff464c75d1cf91c25092be2e9ec92cc Mon Sep 17 00:00:00 2001 From: SJ Date: Sat, 19 Oct 2013 10:39:10 +0200 Subject: [PATCH] display proper oldest record based on the sent date --- util/db-mysql.sql | 1 + util/db-upgrade-0.1.24-vs-0.1.25.sql | 3 +++ webui/model/health/health.php | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/util/db-mysql.sql b/util/db-mysql.sql index 22f0fd6b..1d42e1e3 100644 --- a/util/db-mysql.sql +++ b/util/db-mysql.sql @@ -56,6 +56,7 @@ create index metadata_idx5 on metadata(`deleted`); create index metadata_idx6 on metadata(`arrived`); create index metadata_idx7 on metadata(`retained`); create index metadata_idx8 on metadata(`fromdomain`); +create index metadata_idx9 on metadata(`sent`); create table if not exists `rcpt` ( diff --git a/util/db-upgrade-0.1.24-vs-0.1.25.sql b/util/db-upgrade-0.1.24-vs-0.1.25.sql index e1a0e674..54baf49a 100644 --- a/util/db-upgrade-0.1.24-vs-0.1.25.sql +++ b/util/db-upgrade-0.1.24-vs-0.1.25.sql @@ -2,3 +2,6 @@ alter table `user_settings` add column `ga_enabled` int default 0; alter table `user_settings` add column `ga_secret` varchar(255) default null; +create index metadata_idx9 on metadata(`sent`); + + diff --git a/webui/model/health/health.php b/webui/model/health/health.php index 21f94f87..9cf28f76 100644 --- a/webui/model/health/health.php +++ b/webui/model/health/health.php @@ -169,8 +169,8 @@ class ModelHealthHealth extends Model { public function get_oldest_record_ts() { $data = array(); - $query = $this->db->query("SELECT `sent` AS `oldest_record_ts` FROM " . TABLE_META . " WHERE deleted=0 ORDER BY `arrived` ASC LIMIT 1"); - + $query = $this->db->query("SELECT `sent` AS `oldest_record_ts` FROM " . TABLE_META . " WHERE `deleted`=0 and `sent` > 837381600 ORDER BY `sent` ASC LIMIT 1"); + if(isset($query->rows)) { $data = array_pop($query->rows); } else {