Skip to content

Commit

Permalink
fix(api): removed show of nethserver 8 installations
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaile committed Dec 16, 2022
1 parent 10a088b commit 03657c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/Http/Controllers/InstallationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public function index(IndexInstallationRequest $request): JsonResponse
// retro-compatible query
$query = DB::table('countries')
->selectRaw('countries.name as country_name, countries.code as country_code, installations.data->\'facts\'->>\'version\' as tag, COUNT(installations.data->>\'uuid\') as num')
->join('installations', 'installations.country_id', '=', 'countries.id')->whereRaw('data->>\'installation\' = \'nethserver\'');
->join('installations', 'installations.country_id', '=', 'countries.id')
->whereRaw('data->>\'installation\' = \'nethserver\'')
->whereRaw('data->\'facts\'->\'version\' is not null');
if ($request->get('interval') != '1') {
$query = $query->whereRaw('installations.updated_at > \''.today()->subDays($request->get('interval'))->toDateString().'\'');
}
Expand Down
7 changes: 7 additions & 0 deletions tests/Feature/CompatibilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@
->assertJson([]);
})->skip(fn () => config('database.default') == 'sqlite', 'Cannot run on sqlite.');

test('nethserver 8 installations are not showed', function () {
Installation::factory()->nethserver()->create();
$response = $this->getJson('/api/installation?interval=7')
->assertOk()
->assertJson([]);
})->skip(fn () => config('database.default') == 'sqlite', 'Cannot run on sqlite.');

test('check if interval works', function () {
$installation = Installation::factory()->create();
Installation::factory()->create([
Expand Down

0 comments on commit 03657c5

Please sign in to comment.