mirror of
https://github.com/pelican-dev/panel.git
synced 2026-05-04 18:00:48 +03:00
Remove backup and mount repositories
This commit is contained in:
@@ -3,10 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Exceptions\Http\Connection\DaemonConnectionException;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
@@ -386,4 +388,27 @@ 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 self::query()
|
||||
->backups()
|
||||
->where(fn ($query) => $query->whereNull('completed_at')->orWhere('is_successful', true))
|
||||
->where('created_at', '>=', now()->subSeconds($seconds))
|
||||
->withTrashed()
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a query filtering only non-failed backups for a specific server.
|
||||
*/
|
||||
public function getNonFailedBackups(): HasMany
|
||||
{
|
||||
return $this->backups()->where(
|
||||
fn ($query) => $query->whereNull('completed_at')->orWhere('is_successful', true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user