Skip to content

Commit

Permalink
fix: queries in kernel.php
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbacsai committed Nov 3, 2024
1 parent 52b4e62 commit 9ff73d6
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Kernel extends ConsoleKernel

protected function schedule(Schedule $schedule): void
{
$this->allServers = Server::where('ip', '!=', '1.2.3.4')->get();
$this->allServers = Server::where('ip', '!=', '1.2.3.4');

$this->settings = instanceSettings();

Expand Down Expand Up @@ -76,7 +76,7 @@ protected function schedule(Schedule $schedule): void

private function pullImages($schedule): void
{
$servers = $this->allServers->whereRelation('settings', 'is_usable', true)->whereRelation('settings', 'is_reachable', true);
$servers = $this->allServers->whereRelation('settings', 'is_usable', true)->whereRelation('settings', 'is_reachable', true)->get();
foreach ($servers as $server) {
if ($server->isSentinelEnabled()) {
$schedule->job(function () use ($server) {
Expand Down Expand Up @@ -110,11 +110,11 @@ private function scheduleUpdates($schedule): void
private function checkResources($schedule): void
{
if (isCloud()) {
$servers = $this->allServers->whereNotNull('team.subscription')->where('team.subscription.stripe_trial_already_ended', false);
$servers = $this->allServers->whereHas('team.subscription')->get();
$own = Team::find(0)->servers;
$servers = $servers->merge($own);
} else {
$servers = $this->allServers;
$servers = $this->allServers->get();
}
// $schedule->job(new ResourcesCheck)->everyMinute()->onOneServer();

Expand Down Expand Up @@ -150,14 +150,11 @@ private function checkResources($schedule): void

private function checkScheduledBackups($schedule): void
{
$scheduled_backups = ScheduledDatabaseBackup::all();
$scheduled_backups = ScheduledDatabaseBackup::where('enabled', true)->get();
if ($scheduled_backups->isEmpty()) {
return;
}
foreach ($scheduled_backups as $scheduled_backup) {
if (! $scheduled_backup->enabled) {
continue;
}
if (is_null(data_get($scheduled_backup, 'database'))) {
$scheduled_backup->delete();

Expand All @@ -166,7 +163,7 @@ private function checkScheduledBackups($schedule): void

$server = $scheduled_backup->server();

if (! $server) {
if (is_null($server)) {
continue;
}
$serverTimezone = $server->settings->server_timezone;
Expand Down

0 comments on commit 9ff73d6

Please sign in to comment.