Fixed total days counter to show valid projection on the first day too

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2020-03-14 09:29:10 +01:00
parent 679e71ff4f
commit c34e3ca641

View File

@ -2,14 +2,14 @@
class ControllerHealthWorker extends Controller { class ControllerHealthWorker extends Controller {
private $error = array(); private $error = [];
public function index(){ public function index(){
$archivesizeraw = $sqlsizeraw = $sphinxsizeraw = 0; $archivesizeraw = $sqlsizeraw = $sphinxsizeraw = 0;
$averagemessagesweekraw = $averagemessagesmonthraw = $averagemessagesizeraw = $averagesizedayraw = $averagesqlsizeraw = $averagesphinxsizeraw = 0; $averagemessagesweekraw = $averagemessagesmonthraw = $averagemessagesizeraw = $averagesizedayraw = $averagesqlsizeraw = $averagesphinxsizeraw = 0;
$averagemessagestotalraw = 0; $averagemessagestotalraw = 0;
$this->id = "content"; $this->id = "content";
$this->template = "health/worker.tpl"; $this->template = "health/worker.tpl";
$this->layout = "common/layout-empty"; $this->layout = "common/layout-empty";
@ -68,10 +68,14 @@ class ControllerHealthWorker extends Controller {
$db->select_db($db->database); $db->select_db($db->database);
list($archivesizeraw, $archivestoredsizeraw, $this->data['counters']) = $this->model_stat_counter->get_counters(); list($archivesizeraw, $archivestoredsizeraw, $this->data['counters']) = $this->model_stat_counter->get_counters();
$oldest_record_timestamp = $this->model_health_health->get_oldest_record_ts(); $oldest_record_timestamp = $this->model_health_health->get_oldest_record_ts();
$total_number_days = round( (time() - $this->model_health_health->get_first_email_arrival_ts()) / 86400 ); $total_number_days = round( (time() - $this->model_health_health->get_first_email_arrival_ts()) / 86400 );
if($total_number_days == 0) {
$total_number_days = 1;
}
$this->data['archive_size'] = nice_size($archivesizeraw, ' '); $this->data['archive_size'] = nice_size($archivesizeraw, ' ');
$this->data['archive_stored_size'] = nice_size($archivestoredsizeraw, ' '); $this->data['archive_stored_size'] = nice_size($archivestoredsizeraw, ' ');
@ -81,9 +85,9 @@ class ControllerHealthWorker extends Controller {
$this->data['sysinfo'] = $this->model_health_health->sysinfo(); $this->data['sysinfo'] = $this->model_health_health->sysinfo();
$this->data['options'] = $this->model_health_health->get_options(); $this->data['options'] = $this->model_health_health->get_options();
$sqlsizeraw = $this->model_health_health->get_database_size(); $sqlsizeraw = $this->model_health_health->get_database_size();
$sphinxsizeraw = $this->model_health_health->get_sphinx_size(); $sphinxsizeraw = $this->model_health_health->get_sphinx_size();
@ -126,7 +130,7 @@ class ControllerHealthWorker extends Controller {
foreach($this->data['shortdiskinfo'] as $part) { foreach($this->data['shortdiskinfo'] as $part) {
if( $part['partition'] == DATA_PARTITION ) { $datapart = $part['freespace']*1024; } // if the partition is the selected storage partition, record freespace on that partition if( $part['partition'] == DATA_PARTITION ) { $datapart = $part['freespace']*1024; } // if the partition is the selected storage partition, record freespace on that partition
} }
$this->data['oldestmessagets'] = $oldest_record_timestamp; // date of the oldest record in the db $this->data['oldestmessagets'] = $oldest_record_timestamp; // date of the oldest record in the db
$this->data['averagemessages'] = round($averagemessagesweekraw); // rounded average of messages over the past week $this->data['averagemessages'] = round($averagemessagesweekraw); // rounded average of messages over the past week
$this->data['averagemessagesize'] = nice_size($averagemessagesizeraw,' '); // formatted average message size on disk $this->data['averagemessagesize'] = nice_size($averagemessagesizeraw,' '); // formatted average message size on disk