Skip to content

Commit 396e524

Browse files
authored
Merge pull request #62 from joomla-projects/feature/limit-queue
Don't queue update jobs for currently unhealthy sites
2 parents d306362 + f1d945b commit 396e524

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

app/Console/Commands/QueueUpdates.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Console\Traits\RequestTargetVersion;
66
use App\Jobs\UpdateSite;
77
use App\Models\Site;
8+
use Carbon\Carbon;
89
use Illuminate\Console\Command;
910
use Illuminate\Database\Eloquent\Collection;
1011

@@ -42,22 +43,31 @@ public function handle(): int
4243

4344
$this->output->writeln('Pushing update jobs');
4445

45-
// Get update-ready sites in correct major branch that are not yet on the target version
46+
// Get update-ready sites... that are not yet on the target version
4647
$sites = Site::query()
48+
// ... in correct major version branch
4749
->where(
4850
'cms_version',
4951
'like',
5052
$this->targetVersion[0] . '%'
5153
)
54+
// ... that are not yet on the target version
55+
->where(
56+
'cms_version',
57+
'!=',
58+
$this->targetVersion
59+
)
60+
// ... that match the update requirements
5261
->where(
5362
'update_requirement_state',
5463
'=',
5564
1
5665
)
66+
// ... that have been seen in the last two health check cycles
5767
->where(
58-
'cms_version',
59-
'!=',
60-
$this->targetVersion
68+
'last_seen',
69+
'>',
70+
Carbon::now()->subHours((int) config('autoupdates.healthcheck_interval') * 2) // @phpstan-ignore-line
6171
);
6272

6373
// Query the amount of sites to be updated

0 commit comments

Comments
 (0)