Attempt to fix N+1 issues
This commit is contained in:
@@ -55,6 +55,9 @@ final class TicketShow extends Component
|
||||
|
||||
public function mount(Ticket $ticket): void
|
||||
{
|
||||
Auth::user()?->loadMissing('company');
|
||||
$ticket->loadMissing(['owner.company', 'agent.company']);
|
||||
|
||||
$this->authorize('view', $ticket);
|
||||
$this->ticket = $this->freshTicket($ticket);
|
||||
$this->status_id = $this->ticket->status_id;
|
||||
@@ -295,13 +298,13 @@ final class TicketShow extends Component
|
||||
'ratings',
|
||||
'tags',
|
||||
'checklistItems',
|
||||
'attachments.user',
|
||||
'attachments.user.company',
|
||||
'gitCommits.repository',
|
||||
]) ?? $ticket;
|
||||
|
||||
$comments = \Modules\Helpdesk\Models\Comment::query()
|
||||
->where('ticket_id', $ticket->id)
|
||||
->with(['user', 'attachments.user'])
|
||||
->with(['user.company', 'attachments.user.company'])
|
||||
->oldest()
|
||||
->get();
|
||||
|
||||
@@ -326,7 +329,7 @@ final class TicketShow extends Component
|
||||
$columns[] = 'company_id';
|
||||
}
|
||||
|
||||
$query = User::query()->select($columns)->orderBy('name');
|
||||
$query = User::query()->select($columns)->with('company')->orderBy('name');
|
||||
|
||||
if ($this->ticket->company_id !== null && Schema::hasColumn('users', 'company_id')) {
|
||||
$tenantUsers = (clone $query)
|
||||
|
||||
@@ -197,3 +197,10 @@ versions:
|
||||
- Eager-loaded requester and agent company relations on the ticket detail/edit views to prevent Debugbar N+1 alerts.
|
||||
- Kept agent, status and priority persistence on CSRF-protected POST routes with compact action buttons.
|
||||
- Kept module.json version in sync with changelog.yaml.
|
||||
|
||||
"1.3.11":
|
||||
changed:
|
||||
- Eager-loaded the current user company, ticket requester company, ticket agent company, comment user company and attachment user company on the ticket detail page to remove the remaining Debugbar N+1 alert.
|
||||
- Eager-loaded company data for assignable agent dropdown users without changing agent, status or priority persistence behaviour.
|
||||
- Kept module.json version in sync with changelog.yaml.
|
||||
|
||||
|
||||
@@ -22,5 +22,5 @@
|
||||
"Modules\\Helpdesk\\Providers\\HelpdeskServiceProvider"
|
||||
],
|
||||
"files": [],
|
||||
"version": "1.3.10"
|
||||
"version": "1.3.11"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user