feat(cleanup): add functionality to delete teams with no members or servers in CleanupStuckedResources command
This commit is contained in:
parent
0e27d1f46d
commit
38e947d704
1 changed files with 7 additions and 0 deletions
|
|
@ -20,6 +20,7 @@
|
|||
use App\Models\StandaloneMysql;
|
||||
use App\Models\StandalonePostgresql;
|
||||
use App\Models\StandaloneRedis;
|
||||
use App\Models\Team;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CleanupStuckedResources extends Command
|
||||
|
|
@ -36,6 +37,12 @@ public function handle()
|
|||
private function cleanup_stucked_resources()
|
||||
{
|
||||
try {
|
||||
$teams = Team::all()->filter(function ($team) {
|
||||
return $team->members()->count() === 0 && $team->servers()->count() === 0;
|
||||
});
|
||||
foreach ($teams as $team) {
|
||||
$team->delete();
|
||||
}
|
||||
$servers = Server::all()->filter(function ($server) {
|
||||
return $server->isFunctional();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue