Remove 100 limit on response to events index. Handle there not being a next or prev neighbour.

pull/3787/head
Isaac Connor 2023-11-16 18:00:30 -05:00
parent d62779b1e8
commit 6232cfb8b1
1 changed files with 12 additions and 13 deletions

View File

@ -42,14 +42,14 @@ class EventsController extends AppController {
require_once __DIR__ .'/../../../includes/Event.php';
$allowedMonitors = ($user and $user->unviewableMonitorIds()) ? $user->viewableMonitorIds() : null;
if ( $allowedMonitors ) {
if (count($allowedMonitors)) {
$mon_options = array('Event.MonitorId' => $allowedMonitors);
} else {
$mon_options = '';
}
$named_params = $this->request->params['named'];
if ( $named_params ) {
if ($named_params) {
# In 1.35.13 we renamed StartTime and EndTime to StartDateTime and EndDateTime.
# This hack renames the query string params
foreach ( $named_params as $k=>$v ) {
@ -78,8 +78,10 @@ class EventsController extends AppController {
// with many event APIs. In future, we can
// make a nice ZM_API_ITEMS_PER_PAGE for all pagination
// API
// ICON: 2023-11-16: MontageReview now uses API and unless we specifiy a limit in params, there should be no limit
// TODO: Implement request based limits.
'limit' => '100',
# 'limit' => '100',
'order' => array('StartDateTime'),
'paramType' => 'querystring',
);
@ -153,8 +155,8 @@ class EventsController extends AppController {
# Get the previous and next events for any monitor
$this->Event->id = $id;
$event_neighbors = $this->Event->find('neighbors');
$event['Event']['Next'] = $event_neighbors['next']['Event']['Id'];
$event['Event']['Prev'] = $event_neighbors['prev']['Event']['Id'];
$event['Event']['Next'] = isset($event_neighbors['next']) ? $event_neighbors['next']['Event']['Id'] : 0;
$event['Event']['Prev'] = isset($event_neighbors['prev']) ? $event_neighbors['prev']['Event']['Id'] : 0;
$event['Event']['fileExists'] = $this->Event->fileExists($event['Event']);
$event['Event']['fileSize'] = $this->Event->fileSize($event['Event']);
@ -166,8 +168,8 @@ class EventsController extends AppController {
$event_monitor_neighbors = $this->Event->find('neighbors', array(
'conditions'=>array('Event.MonitorId'=>$event['Event']['MonitorId'])
));
$event['Event']['NextOfMonitor'] = $event_monitor_neighbors['next']['Event']['Id'];
$event['Event']['PrevOfMonitor'] = $event_monitor_neighbors['prev']['Event']['Id'];
$event['Event']['NextOfMonitor'] = isset($event_monitor_neighbors['next']) ? $event_monitor_neighbors['next']['Event']['Id'] : 0;
$event['Event']['PrevOfMonitor'] = isset($event_monitor_neighbors['prev']) ? $event_monitor_neighbors['prev']['Event']['Id'] : 0;
$this->loadModel('Frame');
$maxScoreFrame = $this->Frame->findByEventid($id, 'FrameId', array('Score'=>'desc','FrameId'=>'asc'))['Frame'];
@ -335,12 +337,9 @@ class EventsController extends AppController {
}
array_push($conditions, array("StartDateTime >= DATE_SUB(NOW(), INTERVAL $expr $unit)"));
$query = $this->Event->find('all', array(
'fields' => array(
'MonitorId',
'COUNT(*) AS Count',
),
'conditions' => $conditions,
'group' => 'MonitorId',
'fields' => array('MonitorId', 'COUNT(*) AS Count'),
'conditions' => $conditions,
'group' => 'MonitorId',
));
foreach ($query as $result) {