mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 01:44:45 +02:00
No need for function
This commit is contained in:
parent
0dacfc31ac
commit
a3f33eea3f
@ -387,17 +387,4 @@ class Server extends Model
|
||||
throw new DaemonConnectionException($exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if too many backups have been generated by the server.
|
||||
*/
|
||||
public function getBackupsGeneratedDuringTimespan(int $seconds = 600): array|Collection
|
||||
{
|
||||
return $this
|
||||
->backups()
|
||||
->where(fn ($query) => $query->whereNull('completed_at')->orWhere('is_successful', true))
|
||||
->where('created_at', '>=', now()->subSeconds($seconds))
|
||||
->withTrashed()
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,13 @@ class InitiateBackupService
|
||||
$limit = config('backups.throttles.limit');
|
||||
$period = config('backups.throttles.period');
|
||||
if ($period > 0) {
|
||||
$previous = $server->getBackupsGeneratedDuringTimespan($period);
|
||||
$previous = $server
|
||||
->backups()
|
||||
->where('created_at', '>=', now()->subSeconds($period))
|
||||
->nonFailed()
|
||||
->withTrashed()
|
||||
->get();
|
||||
|
||||
if ($previous->count() >= $limit) {
|
||||
$message = sprintf('Only %d backups may be generated within a %d second span of time.', $limit, $period);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user