From e8a866e5048acce7fddaed60e4364774717c374c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 26 Oct 2023 18:26:51 -0400 Subject: [PATCH] Add named parameters support to ServerStatsController. --- web/api/app/Controller/ServerStatsController.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/web/api/app/Controller/ServerStatsController.php b/web/api/app/Controller/ServerStatsController.php index 80d639aa6..febb6ce5e 100644 --- a/web/api/app/Controller/ServerStatsController.php +++ b/web/api/app/Controller/ServerStatsController.php @@ -38,8 +38,17 @@ class ServerStatsController extends AppController { public function index() { $this->ServerStat->recursive = 0; - $options = ''; - $stats = $this->ServerStat->find('all', $options); + $named_params = $this->request->params['named']; + if ( $named_params ) { + $this->FilterComponent = $this->Components->load('Filter'); + $conditions = $this->FilterComponent->buildFilter($named_params); + } else { + $conditions = array(); + } + + $stats = $this->ServerStat->find('all', ['conditions'=>$conditions, + 'order' => array('TimeStamp ASC'), + ]); $this->set(array( 'serverstats' => $stats, '_serialize' => array('serverstats')