diff --git a/controllers/BatteriesApiController.php b/controllers/BatteriesApiController.php index 651c9100..57f401d7 100644 --- a/controllers/BatteriesApiController.php +++ b/controllers/BatteriesApiController.php @@ -21,7 +21,7 @@ class BatteriesApiController extends BaseApiController public function Current(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) { - return $this->ApiResponse($response, $this->getBatteriesService()->GetCurrent()); + return $this->FilteredApiResponse($response, $this->getBatteriesService()->GetCurrent(), $request->getQueryParams()); } public function TrackChargeCycle(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) diff --git a/migrations/0114.sql b/migrations/0114.sql index 0d46a373..25f1bf53 100644 --- a/migrations/0114.sql +++ b/migrations/0114.sql @@ -17,3 +17,6 @@ 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; + +CREATE VIEW uihelper_batteries_current AS + SELECT battery_id AS id, * FROM batteries_current; diff --git a/services/BatteriesService.php b/services/BatteriesService.php index 7fc4276e..f6157bdc 100644 --- a/services/BatteriesService.php +++ b/services/BatteriesService.php @@ -26,8 +26,7 @@ class BatteriesService extends BaseService public function GetCurrent() { - $sql = 'SELECT * from batteries_current'; - return $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ); + return $this->getDatabase()->uihelper_batteries_current(); } public function TrackChargeCycle(int $batteryId, string $trackedTime)