Moved events queries from the Monitors controller to the Monitors model
This commit is contained in:
parent
a56ae4ed42
commit
d681654e56
|
@ -4,34 +4,10 @@
|
||||||
public function index() {
|
public function index() {
|
||||||
$monitoroptions['fields'] = array('Name', 'Id', 'Function', 'Host');
|
$monitoroptions['fields'] = array('Name', 'Id', 'Function', 'Host');
|
||||||
$this->set('monitors', $this->Monitor->find('all', $monitoroptions));
|
$this->set('monitors', $this->Monitor->find('all', $monitoroptions));
|
||||||
|
$this->set('eventsLastHour', $this->Monitor->getEventsLastHour());
|
||||||
$elhoptions = array(
|
$this->set('eventsLastDay', $this->Monitor->getEventsLastDay());
|
||||||
'conditions' => array('Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 HOUR)'),
|
$this->set('eventsLastWeek', $this->Monitor->getEventsLastWeek());
|
||||||
'group' => array('Event.MonitorId'),
|
$this->set('eventsLastMonth', $this->Monitor->getEventsLastMonth());
|
||||||
'fields' => array('count(Event.Id) AS count')
|
|
||||||
);
|
|
||||||
$this->set('elh', $this->Monitor->Event->find('all', $elhoptions));
|
|
||||||
|
|
||||||
$eldoptions = array(
|
|
||||||
'conditions' => array('Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 DAY)'),
|
|
||||||
'group' => array('Event.MonitorId'),
|
|
||||||
'fields' => array('count(Event.Id) AS count')
|
|
||||||
);
|
|
||||||
$this->set('eld', $this->Monitor->Event->find('all', $eldoptions));
|
|
||||||
|
|
||||||
$elwoptions = array(
|
|
||||||
'conditions' => array('Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 WEEK)'),
|
|
||||||
'group' => array('Event.MonitorId'),
|
|
||||||
'fields' => array('count(Event.Id) AS count')
|
|
||||||
);
|
|
||||||
$this->set('elw', $this->Monitor->Event->find('all', $elwoptions));
|
|
||||||
|
|
||||||
$elmoptions = array(
|
|
||||||
'conditions' => array('Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 MONTH)'),
|
|
||||||
'group' => array('Event.MonitorId'),
|
|
||||||
'fields' => array('count(Event.Id) AS count')
|
|
||||||
);
|
|
||||||
$this->set('elm', $this->Monitor->Event->find('all', $elmoptions));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function view($id = null) {
|
public function view($id = null) {
|
||||||
|
|
|
@ -11,5 +11,33 @@
|
||||||
'foreignKey' => 'MonitorId'
|
'foreignKey' => 'MonitorId'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public function getEventsLastHour() {
|
||||||
|
$conditions = array('Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 HOUR)');
|
||||||
|
$group = array('Event.MonitorId');
|
||||||
|
$fields = array('count(Event.Id) AS count');
|
||||||
|
return $this->Event->find('all', compact('conditions', 'group', 'fields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEventsLastDay() {
|
||||||
|
$conditions = array('Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 DAY)');
|
||||||
|
$group = array('Event.MonitorId');
|
||||||
|
$fields = array('count(Event.Id) AS count');
|
||||||
|
return $this->Event->find('all', compact('conditions', 'group', 'fields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEventsLastWeek() {
|
||||||
|
$conditions = array('Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 WEEK)');
|
||||||
|
$group = array('Event.MonitorId');
|
||||||
|
$fields = array('count(Event.Id) AS count');
|
||||||
|
return $this->Event->find('all', compact('conditions', 'group', 'fields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEventsLastMonth() {
|
||||||
|
$conditions = array('Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 MONTH)');
|
||||||
|
$group = array('Event.MonitorId');
|
||||||
|
$fields = array('count(Event.Id) AS count');
|
||||||
|
return $this->Event->find('all', compact('conditions', 'group', 'fields'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -23,10 +23,10 @@
|
||||||
</td>
|
</td>
|
||||||
<td><?php echo $monitor['Monitor']['Host']; ?></td>
|
<td><?php echo $monitor['Monitor']['Host']; ?></td>
|
||||||
<td><?php echo count($monitor['Event']); ?></td>
|
<td><?php echo count($monitor['Event']); ?></td>
|
||||||
<td><?php echo $elh[$count][0]['count']; ?></td>
|
<td><?php echo $eventsLastHour[$count][0]['count']; ?></td>
|
||||||
<td><?php echo $eld[$count][0]['count']; ?></td>
|
<td><?php echo $eventsLastDay[$count][0]['count']; ?></td>
|
||||||
<td><?php echo $elw[$count][0]['count']; ?></td>
|
<td><?php echo $eventsLastWeek[$count][0]['count']; ?></td>
|
||||||
<td><?php echo $elm[$count][0]['count']; ?></td>
|
<td><?php echo $eventsLastMonth[$count][0]['count']; ?></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><?php echo count($monitor['Zone']); ?></td>
|
<td><?php echo count($monitor['Zone']); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Reference in New Issue