ui(server): fix used backup count (#3526)
* ui(server): fix used backup count * ui(server): refactor backup count code
This commit is contained in:
parent
7e91a33a67
commit
10b357b71e
7 changed files with 41 additions and 32 deletions
|
@ -9,6 +9,7 @@ use Pterodactyl\Models\Backup;
|
|||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Pterodactyl\Extensions\Backups\BackupManager;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Pterodactyl\Repositories\Eloquent\BackupRepository;
|
||||
use Pterodactyl\Repositories\Wings\DaemonBackupRepository;
|
||||
use Pterodactyl\Exceptions\Service\Backup\TooManyBackupsException;
|
||||
|
@ -134,10 +135,7 @@ class InitiateBackupService
|
|||
|
||||
// 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.
|
||||
$successful = $server->backups()->where(function ($query) {
|
||||
$query->whereNull('completed_at')
|
||||
->orWhere('is_successful', true);
|
||||
});
|
||||
$successful = $this->repository->getNonFailedBackups($server);
|
||||
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.
|
||||
if (!$override || $server->backup_limit <= 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue