Skip to content

Commit

Permalink
cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SniperSister committed Nov 16, 2024
1 parent 8dcd6e4 commit 680440f
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 11 deletions.
7 changes: 4 additions & 3 deletions app/Console/Commands/PerformSiteHealthCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ class PerformSiteHealthCheck extends Command
*/
public function handle(): int
{
CheckSiteHealth::dispatchSync(
Site::findOrFail($this->input->getArgument('siteId'))
);
/** @var Site $site */
$site = Site::findOrFail($this->input->getArgument('siteId'));

CheckSiteHealth::dispatchSync($site);

return Command::SUCCESS;
}
Expand Down
8 changes: 6 additions & 2 deletions app/Console/Commands/QueueHealthChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ public function handle(): int
$this->output->writeln('Pushing pending health checks');

Site::query()
->whereDate('last_seen', '<', Carbon::now()->subHours(env('HEALTH_CHECK_INTERVAL', 24)))
->whereDate(
'last_seen',
'<',
Carbon::now()->subHours((int) config('autoupdates.healthcheck_interval')) // @phpstan-ignore-line
)
->chunkById(
100,
function (Collection $chunk) {
Expand All @@ -44,7 +48,7 @@ function (Collection $chunk) {
$this->totalPushed += $chunk->count();

// Push each site check to queue
$chunk->each(fn($site) => CheckSiteHealth::dispatch($site));
$chunk->each(fn ($site) => CheckSiteHealth::dispatch($site));
}
);

Expand Down
1 change: 1 addition & 0 deletions app/Jobs/CheckSiteHealth.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function handle(): void
])->toArray()
);

// @phpstan-ignore-next-line
$this->site->last_seen = Carbon::now();
$this->site->save();
}
Expand Down
15 changes: 13 additions & 2 deletions app/Services/SiteConnectionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,23 @@ protected function performHttpRequest(
);
}

// Return decoded body
return json_decode(
// Decode body
$return = json_decode(
(string) $response->getBody(),
true,
512,
JSON_THROW_ON_ERROR
);

// Make sure it's an array
if (!is_array($return)) {
throw new RequestException(
"Invalid JSON body",
$request,
$response
);
}

return $return;
}
}
3 changes: 1 addition & 2 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,5 @@
'maintenance' => [
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
'store' => env('APP_MAINTENANCE_STORE', 'database'),
],

]
];
5 changes: 5 additions & 0 deletions config/autoupdates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'healthcheck_interval' => env('HEALTH_CHECK_INTERVAL', 24)
];
7 changes: 5 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ parameters:
paths:
- app/

# Level 9 is the highest level
level: 5
level: 9

ignoreErrors:
- '#Method .* return type has no value type specified in iterable type array.#'
- '#Method .* has parameter .* with no value type specified in iterable type array.#'

0 comments on commit 680440f

Please sign in to comment.