refactor(deployment): enhance deployment data retrieval and relationships
- Updated the deployments method in DeploymentsIndicator to include application environment and project relationships for better data context. - Refactored the application method in ApplicationDeploymentQueue to use Eloquent relationships instead of manual fetching, improving performance and readability. - Enhanced the deployments indicator view to display application environment and project names, providing clearer deployment context.
This commit is contained in:
parent
158747c8b1
commit
4b947a0d64
3 changed files with 7 additions and 5 deletions
|
|
@ -16,7 +16,8 @@ public function deployments()
|
||||||
{
|
{
|
||||||
$servers = Server::ownedByCurrentTeam()->get();
|
$servers = Server::ownedByCurrentTeam()->get();
|
||||||
|
|
||||||
return ApplicationDeploymentQueue::whereIn('status', ['in_progress', 'queued'])
|
return ApplicationDeploymentQueue::with(['application.environment.project'])
|
||||||
|
->whereIn('status', ['in_progress', 'queued'])
|
||||||
->whereIn('server_id', $servers->pluck('id'))
|
->whereIn('server_id', $servers->pluck('id'))
|
||||||
->orderBy('id')
|
->orderBy('id')
|
||||||
->get([
|
->get([
|
||||||
|
|
|
||||||
|
|
@ -41,11 +41,9 @@ class ApplicationDeploymentQueue extends Model
|
||||||
{
|
{
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
public function application(): Attribute
|
public function application()
|
||||||
{
|
{
|
||||||
return Attribute::make(
|
return $this->belongsTo(Application::class);
|
||||||
get: fn () => Application::find($this->application_id),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function server(): Attribute
|
public function server(): Attribute
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,9 @@ class="flex items-start gap-3 p-3 rounded-lg dark:bg-coolgray-200 bg-gray-50 tra
|
||||||
{{ $deployment->application_name }}
|
{{ $deployment->application_name }}
|
||||||
</div>
|
</div>
|
||||||
<p class="text-xs dark:text-neutral-400 text-gray-600 mt-1">
|
<p class="text-xs dark:text-neutral-400 text-gray-600 mt-1">
|
||||||
|
{{ $deployment->application?->environment?->project?->name }} / {{ $deployment->application?->environment?->name }}
|
||||||
|
</p>
|
||||||
|
<p class="text-xs dark:text-neutral-400 text-gray-600">
|
||||||
{{ $deployment->server_name }}
|
{{ $deployment->server_name }}
|
||||||
</p>
|
</p>
|
||||||
@if ($deployment->pull_request_id)
|
@if ($deployment->pull_request_id)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue