From 30516e472bbdb83ab57c8ef6e09ea3fa6eadf26f Mon Sep 17 00:00:00 2001 From: fipwmaqzufheoxq92ebc <29818044+fipwmaqzufheoxq92ebc@users.noreply.github.com> Date: Tue, 1 Sep 2020 15:49:50 +0200 Subject: [PATCH] Use FilteredApiResponse for current chores --- controllers/ChoresApiController.php | 2 +- migrations/0114.sql | 4 ++++ services/ChoresService.php | 3 +-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/controllers/ChoresApiController.php b/controllers/ChoresApiController.php index 71345367..10673514 100644 --- a/controllers/ChoresApiController.php +++ b/controllers/ChoresApiController.php @@ -58,7 +58,7 @@ class ChoresApiController extends BaseApiController public function Current(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) { - return $this->ApiResponse($response, $this->getChoresService()->GetCurrent()); + return $this->FilteredApiResponse($response, $this->getChoresService()->GetCurrent(), $request->getQueryParams()); } public function TrackChoreExecution(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) diff --git a/migrations/0114.sql b/migrations/0114.sql index 6afd7fd4..0d46a373 100644 --- a/migrations/0114.sql +++ b/migrations/0114.sql @@ -13,3 +13,7 @@ SELECT id, END ) AS display_name FROM users; +CREATE VIEW uihelper_chores_current AS +SELECT chores_current.*, chores.name AS chore_name +from chores_current + join chores on chores_current.chore_id = chores.id; diff --git a/services/ChoresService.php b/services/ChoresService.php index 6f161293..bd7387b2 100644 --- a/services/ChoresService.php +++ b/services/ChoresService.php @@ -152,8 +152,7 @@ class ChoresService extends BaseService public function GetCurrent() { - $sql = 'SELECT chores_current.*, chores.name AS chore_name from chores_current join chores on chores_current.chore_id = chores.id'; - return $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ); + return $this->getDatabase()->uihelper_chores_current(); } public function TrackChore(int $choreId, string $trackedTime, $doneBy = GROCY_USER_ID)