Inline many variables.

This commit is contained in:
Lucas Michot
2024-10-31 18:20:11 +01:00
parent aa7fa16c74
commit 1ec224fde1
20 changed files with 34 additions and 79 deletions

View File

@@ -58,9 +58,7 @@ class StartProxy
}
if ($async) {
$activity = remote_process($commands, $server, callEventOnFinish: 'ProxyStarted', callEventData: $server);
return $activity;
return remote_process($commands, $server, callEventOnFinish: 'ProxyStarted', callEventData: $server);
} else {
instant_remote_process($commands, $server);
$server->proxy->set('status', 'running');

View File

@@ -12,8 +12,6 @@ class RunCommand
public function handle(Server $server, $command)
{
$activity = remote_process(command: [$command], server: $server, ignore_errors: true, type: ActivityTypes::COMMAND->value);
return $activity;
return remote_process(command: [$command], server: $server, ignore_errors: true, type: ActivityTypes::COMMAND->value);
}
}

View File

@@ -33,8 +33,7 @@ class StartService
$commands[] = "docker network connect --alias {$serviceName}-{$service->uuid} $network {$serviceName}-{$service->uuid} >/dev/null 2>&1 || true";
}
}
$activity = remote_process($commands, $service->server, type_uuid: $service->uuid, callEventOnFinish: 'ServiceStatusChanged');
return $activity;
return remote_process($commands, $service->server, type_uuid: $service->uuid, callEventOnFinish: 'ServiceStatusChanged');
}
}

View File

@@ -1691,9 +1691,8 @@ class ApplicationsController extends Controller
'standalone_postgresql_id',
'standalone_redis_id',
]);
$env = $this->removeSensitiveData($env);
return $env;
return $this->removeSensitiveData($env);
});
return response()->json($envs);

View File

@@ -566,9 +566,8 @@ class ServicesController extends Controller
'standalone_postgresql_id',
'standalone_redis_id',
]);
$env = $this->removeSensitiveData($env);
return $env;
return $this->removeSensitiveData($env);
});
return response()->json($envs);

View File

@@ -54,13 +54,9 @@ class ScheduledTaskJob implements ShouldQueue
private function getServerTimezone(): string
{
if ($this->resource instanceof Application) {
$timezone = $this->resource->destination->server->settings->server_timezone;
return $timezone;
return $this->resource->destination->server->settings->server_timezone;
} elseif ($this->resource instanceof Service) {
$timezone = $this->resource->server->settings->server_timezone;
return $timezone;
return $this->resource->server->settings->server_timezone;
}
return 'UTC';

View File

@@ -119,9 +119,8 @@ class BackupExecutions extends Component
if (! $server) {
return 'UTC';
}
$serverTimezone = $server->settings->server_timezone;
return $serverTimezone;
return $server->settings->server_timezone;
}
public function formatDateInServerTimezone($date)

View File

@@ -54,9 +54,8 @@ class Executions extends Component
if (! $server) {
return 'UTC';
}
$serverTimezone = $server->settings->server_timezone;
return $serverTimezone;
return $server->settings->server_timezone;
}
public function formatDateInServerTimezone($date)

View File

@@ -34,21 +34,15 @@ class ScheduledTask extends BaseModel
{
if ($this->application) {
if ($this->application->destination && $this->application->destination->server) {
$server = $this->application->destination->server;
return $server;
return $this->application->destination->server;
}
} elseif ($this->service) {
if ($this->service->destination && $this->service->destination->server) {
$server = $this->service->destination->server;
return $server;
return $this->service->destination->server;
}
} elseif ($this->database) {
if ($this->database->destination && $this->database->destination->server) {
$server = $this->database->destination->server;
return $server;
return $this->database->destination->server;
}
}

View File

@@ -602,11 +602,10 @@ $schema://$host {
throw new \Exception($error);
}
$cpu = json_decode($cpu, true);
$parsedCollection = collect($cpu)->map(function ($metric) {
return collect($cpu)->map(function ($metric) {
return [(int) $metric['time'], (float) $metric['percent']];
});
return $parsedCollection;
}
}
@@ -837,9 +836,7 @@ $schema://$host {
{
return Attribute::make(
get: function ($value) {
$sanitizedValue = preg_replace('/[^A-Za-z0-9\-_]/', '', $value);
return $sanitizedValue;
return preg_replace('/[^A-Za-z0-9\-_]/', '', $value);
}
);
}
@@ -1096,9 +1093,7 @@ $schema://$host {
public function installDocker()
{
$activity = InstallDocker::run($this);
return $activity;
return InstallDocker::run($this);
}
public function validateDockerEngine($throwError = false)

View File

@@ -1307,9 +1307,7 @@ class Service extends BaseModel
public function networks()
{
$networks = getTopLevelNetworks($this);
return $networks;
return getTopLevelNetworks($this);
}
protected function isDeployable(): Attribute

View File

@@ -131,9 +131,7 @@ class Team extends Model implements SendsDiscord, SendsEmail
{
$recipients = data_get($notification, 'emails', null);
if (is_null($recipients)) {
$recipients = $this->members()->pluck('email')->toArray();
return $recipients;
return $this->members()->pluck('email')->toArray();
}
return explode(',', $recipients);
@@ -251,9 +249,8 @@ class Team extends Model implements SendsDiscord, SendsEmail
$sources = collect([]);
$github_apps = $this->hasMany(GithubApp::class)->whereisPublic(false)->get();
$gitlab_apps = $this->hasMany(GitlabApp::class)->whereisPublic(false)->get();
$sources = $sources->merge($github_apps)->merge($gitlab_apps);
return $sources;
return $sources->merge($github_apps)->merge($gitlab_apps);
}
public function s3s()

View File

@@ -58,14 +58,12 @@ class StatusChanged extends Notification implements ShouldQueue
public function toDiscord(): DiscordMessage
{
$message = new DiscordMessage(
return new DiscordMessage(
title: ':cross_mark: Application stopped',
description: '[Open Application in Coolify]('.$this->resource_url.')',
color: DiscordMessage::errorColor(),
isCritical: true,
);
return $message;
}
public function toTelegram(): array