Skip to content

Commit

Permalink
Also list checkouts in request API
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Dec 19, 2024
1 parent 8f87ad4 commit b9fc427
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/Cavil/Model/Requests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ sub add ($self, $link, $pkg) {

sub all ($self) {
return $self->pg->db->query(
'select external_link, array_agg(package) as packages from bot_requests
group by external_link'
'SELECT br.external_link, array_agg(br.package) AS packages, array_agg(bp.checkout_dir) AS checkouts
FROM bot_requests br JOIN bot_packages bp ON (br.package = bp.id)
GROUP BY br.external_link'
)->hashes->to_array;
}

Expand Down
3 changes: 2 additions & 1 deletion t/api.t
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ subtest 'Create a requests' => sub {

subtest 'Request has been created' => sub {
$t->get_ok('/requests' => {Authorization => 'Token test_token'})->status_is(200)
->json_is('/requests/0/external_link', 'obs#123')->json_is('/requests/0/packages', [1]);
->json_is('/requests/0/external_link', 'obs#123')->json_is('/requests/0/packages', [1])
->json_is('/requests/0/checkouts', ['236d7b56886a0d2799c0d114eddbb7f1']);
};

subtest 'Remove request again' => sub {
Expand Down

0 comments on commit b9fc427

Please sign in to comment.