Refactor restart tracking and add missing model casts
- Consolidate duplicate restart tracking logic in GetContainersStatus - Add last_restart_type string cast to all 8 standalone database models 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
6d47d24169
commit
d04d0ab499
9 changed files with 17 additions and 18 deletions
|
|
@ -206,28 +206,19 @@ public function handle(Server $server, ?Collection $containers = null, ?Collecti
|
|||
|
||||
if ($statusFromDb !== $containerStatus) {
|
||||
$updateData = ['status' => $containerStatus];
|
||||
|
||||
// Update restart tracking if restart count increased
|
||||
if ($restartCount > $previousRestartCount) {
|
||||
$updateData['restart_count'] = $restartCount;
|
||||
$updateData['last_restart_at'] = now();
|
||||
$updateData['last_restart_type'] = 'crash';
|
||||
}
|
||||
|
||||
$database->update($updateData);
|
||||
} else {
|
||||
$updateData = ['last_online_at' => now()];
|
||||
|
||||
// Update restart tracking even if status unchanged
|
||||
if ($restartCount > $previousRestartCount) {
|
||||
$updateData['restart_count'] = $restartCount;
|
||||
$updateData['last_restart_at'] = now();
|
||||
$updateData['last_restart_type'] = 'crash';
|
||||
}
|
||||
|
||||
$database->update($updateData);
|
||||
}
|
||||
|
||||
// Update restart tracking if restart count increased
|
||||
if ($restartCount > $previousRestartCount) {
|
||||
$updateData['restart_count'] = $restartCount;
|
||||
$updateData['last_restart_at'] = now();
|
||||
$updateData['last_restart_type'] = 'crash';
|
||||
}
|
||||
|
||||
$database->update($updateData);
|
||||
|
||||
if ($isPublic) {
|
||||
$foundTcpProxy = $this->containers->filter(function ($value, $key) use ($uuid) {
|
||||
if ($this->server->isSwarm()) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class StandaloneClickhouse extends BaseModel
|
|||
'clickhouse_password' => 'encrypted',
|
||||
'restart_count' => 'integer',
|
||||
'last_restart_at' => 'datetime',
|
||||
'last_restart_type' => 'string',
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class StandaloneDragonfly extends BaseModel
|
|||
'dragonfly_password' => 'encrypted',
|
||||
'restart_count' => 'integer',
|
||||
'last_restart_at' => 'datetime',
|
||||
'last_restart_type' => 'string',
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class StandaloneKeydb extends BaseModel
|
|||
'keydb_password' => 'encrypted',
|
||||
'restart_count' => 'integer',
|
||||
'last_restart_at' => 'datetime',
|
||||
'last_restart_type' => 'string',
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class StandaloneMariadb extends BaseModel
|
|||
'mariadb_password' => 'encrypted',
|
||||
'restart_count' => 'integer',
|
||||
'last_restart_at' => 'datetime',
|
||||
'last_restart_type' => 'string',
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class StandaloneMongodb extends BaseModel
|
|||
protected $casts = [
|
||||
'restart_count' => 'integer',
|
||||
'last_restart_at' => 'datetime',
|
||||
'last_restart_type' => 'string',
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class StandaloneMysql extends BaseModel
|
|||
'mysql_root_password' => 'encrypted',
|
||||
'restart_count' => 'integer',
|
||||
'last_restart_at' => 'datetime',
|
||||
'last_restart_type' => 'string',
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class StandalonePostgresql extends BaseModel
|
|||
'postgres_password' => 'encrypted',
|
||||
'restart_count' => 'integer',
|
||||
'last_restart_at' => 'datetime',
|
||||
'last_restart_type' => 'string',
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class StandaloneRedis extends BaseModel
|
|||
protected $casts = [
|
||||
'restart_count' => 'integer',
|
||||
'last_restart_at' => 'datetime',
|
||||
'last_restart_type' => 'string',
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
|
|
|
|||
Loading…
Reference in a new issue