Skip to content

Commit 057ef73

Browse files
committed
unfucking my fucks
1 parent dfddf0f commit 057ef73

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

glued/Controllers/IfController.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,14 @@ public function getServices(Request $request, Response $response, array $args =
6464

6565
public function getDeployments(Request $request, Response $response, array $args = []): Response
6666
{
67-
$path = explode('/', trim($request->getUri()->getPath(), '/'));
68-
if (implode('/', array_slice($path, 0, 3)) !== 'api/if/svc' || !isset($path[3])) {
69-
throw new \Exception('Invalid path');
67+
$db = new Sql($this->pg, 'if__deployments');
68+
$qp = $request->getQueryParams();
69+
$filters = ['uuid', 'service'];
70+
foreach ($filters as $filter) {
71+
if (!empty($qp[$filter])) { $db->where($filter, '=', $qp[$filter]); }
7072
}
71-
$service = $path[3];
72-
$this->deployments->where('service', '=', $service);
73-
$this->deployments->selectModifier = "jsonb_build_object('uri', concat('{$this->settings['glued']['baseuri']}{$this->settings['routes']['be_if']['pattern']}svc/', doc->>'service', '/v1/', doc->>'uuid')) || ";
74-
$data = $this->deployments->getAll();
75-
$xfi = new ArrayTransformer();
76-
$xfi->map('uri', 'uri', 'required')
77-
->map('uuid', 'uuid', 'required')
78-
->map('name', 'name', 'required')
79-
->map('description', 'description');
80-
$data = $xfi->toArrays($data);
73+
$db->selectModifier = "jsonb_build_object('uri', concat('{$this->settings['glued']['baseuri']}{$this->settings['routes']['be_if']['pattern']}svc/', doc->>'service', '/v1/', doc->>'uuid'), 'nonce', nonce, 'created_at', created_at, 'updated_at', updated_at) || ";
74+
$data = $db->getAll();
8175
return $response->withJson($data);
8276
}
8377

0 commit comments

Comments
 (0)