Skip to content

Commit

Permalink
fix(admin): n+1 query when getting participant and presenter counts
Browse files Browse the repository at this point in the history
  • Loading branch information
jxjj committed Oct 14, 2024
1 parent e937711 commit 4b586a7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/Nova/Chime.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class Chime extends Resource
'name',
];

public static function indexQuery(NovaRequest $request, $query)
{
return $query->withCount(['presenters', 'participants']);
}

/**
* Get the fields displayed by the resource.
*
Expand All @@ -62,11 +67,11 @@ public function fields(NovaRequest $request)
Text::make('Name')->sortable()->rules('required', 'max:255'),

Number::make('Presenters', function () {
return $this->presenters()->count();
return $this->presenters_count;
})->onlyOnIndex(),

Number::make('Participants', function () {
return $this->participants()->count();
return $this->participants_count;
})->onlyOnIndex(),

Boolean::make('Canvas Chime', 'lti_return_url'),
Expand Down

0 comments on commit 4b586a7

Please sign in to comment.