backups: properly query backups
This commit is contained in:
parent
c46131e7ad
commit
07617bcd27
2 changed files with 8 additions and 3 deletions
|
@ -25,8 +25,10 @@ class BackupRepository extends EloquentRepository
|
||||||
return $this->getBuilder()
|
return $this->getBuilder()
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->where('server_id', $server)
|
->where('server_id', $server)
|
||||||
->whereNull('completed_at')
|
->where(function ($query) {
|
||||||
->orWhere('is_successful', '=', true)
|
$query->whereNull('completed_at')
|
||||||
|
->orWhere('is_successful', '=', true);
|
||||||
|
})
|
||||||
->where('created_at', '>=', Carbon::now()->subSeconds($seconds)->toDateTimeString())
|
->where('created_at', '>=', Carbon::now()->subSeconds($seconds)->toDateTimeString())
|
||||||
->get()
|
->get()
|
||||||
->toBase();
|
->toBase();
|
||||||
|
|
|
@ -134,7 +134,10 @@ class InitiateBackupService
|
||||||
|
|
||||||
// Check if the server has reached or exceeded its backup limit.
|
// Check if the server has reached or exceeded its backup limit.
|
||||||
// completed_at == null will cover any ongoing backups, while is_successful == true will cover any completed backups.
|
// completed_at == null will cover any ongoing backups, while is_successful == true will cover any completed backups.
|
||||||
$successful = $server->backups()->whereNull('completed_at')->orWhere('is_successful', true);
|
$successful = $server->backups()->where(function ($query) {
|
||||||
|
$query->whereNull('completed_at')
|
||||||
|
->orWhere('is_successful', true);
|
||||||
|
});
|
||||||
if (!$server->backup_limit || $successful->count() >= $server->backup_limit) {
|
if (!$server->backup_limit || $successful->count() >= $server->backup_limit) {
|
||||||
// Do not allow the user to continue if this server is already at its limit and can't override.
|
// Do not allow the user to continue if this server is already at its limit and can't override.
|
||||||
if (!$override || $server->backup_limit <= 0) {
|
if (!$override || $server->backup_limit <= 0) {
|
||||||
|
|
Loading…
Reference in a new issue