From c5e838fa33bab88f1c7b8f0a14dc31f18861de72 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Mon, 9 Mar 2020 11:09:20 -0400 Subject: [PATCH 1/3] return global frame IDs of snapshot and alarm frames for a specific event --- web/api/app/Controller/EventsController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/api/app/Controller/EventsController.php b/web/api/app/Controller/EventsController.php index d9ad29b0d..71d9633a0 100644 --- a/web/api/app/Controller/EventsController.php +++ b/web/api/app/Controller/EventsController.php @@ -149,6 +149,10 @@ class EventsController extends AppController { )); $event['Event']['NextOfMonitor'] = $event_monitor_neighbors['next']['Event']['Id']; $event['Event']['PrevOfMonitor'] = $event_monitor_neighbors['prev']['Event']['Id']; + + $this->loadModel('Frame'); + $event['Event']['MaxScoreFrameId'] = $this->Frame->findByEventid($id,'Score','Score DESC')['Frame']['Score']; + $event['Event']['AlarmFrameId'] = $this->Frame->findByEventidAndType($id,'Alarm')['Frame']['Id']; $this->set(array( 'event' => $event, From 3611d147e6ba7952a24a54e46d4b53a73c992c78 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Mon, 9 Mar 2020 11:25:07 -0400 Subject: [PATCH 2/3] fix score frameID to return ID not Score --- web/api/app/Controller/EventsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/api/app/Controller/EventsController.php b/web/api/app/Controller/EventsController.php index 71d9633a0..2a0f735eb 100644 --- a/web/api/app/Controller/EventsController.php +++ b/web/api/app/Controller/EventsController.php @@ -151,7 +151,7 @@ class EventsController extends AppController { $event['Event']['PrevOfMonitor'] = $event_monitor_neighbors['prev']['Event']['Id']; $this->loadModel('Frame'); - $event['Event']['MaxScoreFrameId'] = $this->Frame->findByEventid($id,'Score','Score DESC')['Frame']['Score']; + $event['Event']['MaxScoreFrameId'] = $this->Frame->findByEventid($id,'Id','Score DESC')['Frame']['Id']; $event['Event']['AlarmFrameId'] = $this->Frame->findByEventidAndType($id,'Alarm')['Frame']['Id']; $this->set(array( From a261efe0a7ddda110dbb2c7fed62a35184b14ac2 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Mon, 9 Mar 2020 12:04:40 -0400 Subject: [PATCH 3/3] return relative frameId, also sort score frame by lowest frame to avoid bulk frames incase score is 0 --- web/api/app/Controller/EventsController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/api/app/Controller/EventsController.php b/web/api/app/Controller/EventsController.php index 2a0f735eb..5188c18b4 100644 --- a/web/api/app/Controller/EventsController.php +++ b/web/api/app/Controller/EventsController.php @@ -151,8 +151,8 @@ class EventsController extends AppController { $event['Event']['PrevOfMonitor'] = $event_monitor_neighbors['prev']['Event']['Id']; $this->loadModel('Frame'); - $event['Event']['MaxScoreFrameId'] = $this->Frame->findByEventid($id,'Id','Score DESC')['Frame']['Id']; - $event['Event']['AlarmFrameId'] = $this->Frame->findByEventidAndType($id,'Alarm')['Frame']['Id']; + $event['Event']['MaxScoreFrameId'] = $this->Frame->findByEventid($id,'FrameId',array('Score'=>'desc','FrameId'=>'asc'))['Frame']['FrameId']; + $event['Event']['AlarmFrameId'] = $this->Frame->findByEventidAndType($id,'Alarm')['Frame']['FrameId']; $this->set(array( 'event' => $event,