Skip to content

Commit

Permalink
Review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
edwh committed Nov 12, 2024
1 parent 0b5ebb9 commit 1ea24f2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/Http/Controllers/API/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public static function getGroupList()
* tags={"Groups"},
* summary="Get list of group names",
* @OA\Parameter(
* name="archived",
* name="includeArchived",
* description="Include archived groups",
* required=false,
* in="query",
Expand Down Expand Up @@ -262,13 +262,13 @@ public static function getGroupList()

public static function listNamesv2(Request $request) {
$request->validate([
'archived' => ['string', 'in:true,false'],
'includeArchived' => ['string', 'in:true,false'],
]);

// We only return the group id and name, for speed.
$query = Group::select('idgroups', 'name', 'archived_at');

if (!$request->has('archived') || $request->get('archived') == 'false') {
if (!$request->has('includeArchived') || $request->get('includeArchived') == 'false') {
$query = $query->whereNull('archived_at');
}

Expand Down
11 changes: 10 additions & 1 deletion app/Http/Controllers/API/NetworkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ public function getNetworkv2($id)
* type="boolean"
* )
* ),
* @OA\Parameter(
* name="includeArchived",
* description="Include archived groups",
* required=false,
* in="query",
* @OA\Schema(
* type="boolean"
* )
* ),
* @OA\Response(
* response=200,
* description="Successful operation",
Expand Down Expand Up @@ -176,7 +185,7 @@ public function getNetworkGroupsv2(Request $request, $id)
->where('groups.updated_at', '>=', $start)
->where('groups.updated_at', '<=', $end);

if (!$request->has('archived') || $request->get('archived') == 'false') {
if (!$request->has('includeArchived') || $request->get('includeArchived') == 'false') {
$query = $query->whereNull('archived_at');
}

Expand Down
1 change: 1 addition & 0 deletions database/migrations/2024_09_16_093650_inactive_groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function up()
$group->archived_at = $group->updated_at;

// Remove [INACTIVE] from the group name - this is now indicated via archived_at.
$group->name = str_replace('[INACTIVE] ', '', $group->name);
$group->name = str_replace('[INACTIVE]', '', $group->name);
$group->save();
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/Groups/APIv2GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,14 @@ public function testArchived() {

$this->assertGroupFound($groups, $idgroups, false);

$response = $this->get('/api/v2/groups/names?archived=true');
$response = $this->get('/api/v2/groups/names?includeArchived=true');
$response->assertSuccessful();
$json = json_decode($response->getContent(), true);
$groups = $json['data'];
$ix = $this->assertGroupFound($groups, $idgroups, true);
$this->assertEquals('2022-01-01T00:00:00+00:00', $groups[$ix]['archived_at']);

$response = $this->get('/api/v2/groups/names?archived=false');
$response = $this->get('/api/v2/groups/names?includeArchived=false');
$response->assertSuccessful();
$json = json_decode($response->getContent(), true);
$groups = $json['data'];
Expand All @@ -543,7 +543,7 @@ public function testArchived() {
$groups = $json['data'];
$this->assertGroupFound($groups, $idgroups, false);

$response = $this->get("/api/v2/networks/{$network->id}/groups?archived=true");
$response = $this->get("/api/v2/networks/{$network->id}/groups?includeArchived=true");
$response->assertSuccessful();
$json = json_decode($response->getContent(), true);
$groups = $json['data'];
Expand Down

0 comments on commit 1ea24f2

Please sign in to comment.