Eventgrid: Use $query->hasResult() instead of $query->count()

* and do not use fetchAll()
* and do not use <? short tags
* and do not use curly braces if not absolutely necessary..

refs 
This commit is contained in:
Johannes Meyer 2015-08-03 16:06:21 +02:00
parent 57e0ce1b53
commit f03b9e5769
2 changed files with 16 additions and 16 deletions
modules/monitoring/application
controllers
views/scripts/list

@ -368,7 +368,7 @@ class Monitoring_ListController extends Controller
$this->view->filter = Filter::fromQuerystring((string) $this->params);
$query->applyFilter($this->view->filter);
$this->applyRestriction('monitoring/filter/objects', $query);
$this->view->summary = $query->getQuery()->fetchAll();
$this->view->summary = $query;
$this->view->column = $form->getValue('state');
// $this->view->orientationBox = $orientationBox;
$this->view->orientation = $orientation;

@ -15,11 +15,6 @@ if (! $this->compact): ?>
<div class="content" data-base-target="_next">
<?php
if (count($summary) === 0) {
echo $this->translate('No state changes in the selected time period.') . '</div>';
return;
}
$settings = array(
'cnt_up' => array(
'tooltip' => $this->translate('%d hosts ok on %s'),
@ -60,14 +55,6 @@ $settings = array(
)
);
$from = intval($form->getValue('from', strtotime('3 months ago')));
$to = intval($form->getValue('to', time()));
// don't display more than ten years, or else this will get really slow
if ($to - $from > 315360000) {
$from = $to - 315360000;
}
$data = array();
foreach ($summary as $entry) {
$day = $entry->day;
@ -90,6 +77,19 @@ foreach ($summary as $entry) {
);
}
if (! $summary->hasResult()) {
echo $this->translate('No state changes in the selected time period.') . '</div>';
return;
}
$from = intval($form->getValue('from', strtotime('3 months ago')));
$to = intval($form->getValue('to', time()));
// don't display more than ten years, or else this will get really slow
if ($to - $from > 315360000) {
$from = $to - 315360000;
}
$f = new DateTime();
$f->setTimestamp($from);
$t = new DateTime();
@ -117,11 +117,11 @@ for ($i = 0; $i < $diff->days; $i += $step) {
}
?>
<div style="width: 33.5em;">
<? foreach (array_reverse($grids) as $key => $grid) { ?>
<?php foreach (array_reverse($grids) as $key => $grid): ?>
<div style=" <?= $this->orientation === 'horizontal' ? '' : 'display: inline-block; vertical-align: top; top; margin: 0.5em;' ?>">
<?= $grid; ?>
<?= $this->orientation === 'horizontal' ? '<br />' : '' ?>
</div>
<? } ?>
<?php endforeach ?>
</div>
</div>