Skip to content

Commit

Permalink
fix(browse): add additional eager loading (#1183)
Browse files Browse the repository at this point in the history
  • Loading branch information
itinerare authored Jan 8, 2025
1 parent d4ca0b1 commit 812a4c6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/Http/Controllers/BrowseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BrowseController extends Controller {
* @return \Illuminate\Contracts\Support\Renderable
*/
public function getUsers(Request $request) {
$query = User::visible()->join('ranks', 'users.rank_id', '=', 'ranks.id')->select('ranks.name AS rank_name', 'users.*');
$query = User::visible()->with('primaryAlias')->join('ranks', 'users.rank_id', '=', 'ranks.id')->select('ranks.name AS rank_name', 'users.*');
$sort = $request->only(['sort']);

if ($request->get('name')) {
Expand Down Expand Up @@ -106,7 +106,7 @@ public function getDeactivated(Request $request) {
'canView' => $canView,
'privacy' => $privacy,
'key' => $key,
'users' => $canView ? User::where('is_deactivated', 1)->orderBy('users.name')->paginate(30)->appends($request->query()) : null,
'users' => $canView ? User::where('is_deactivated', 1)->with('primaryAlias', 'settings')->orderBy('users.name')->paginate(30)->appends($request->query()) : null,
]);
}

Expand Down Expand Up @@ -137,7 +137,7 @@ public function getBlacklist(Request $request) {
'canView' => $canView,
'privacy' => $privacy,
'key' => $key,
'users' => $canView ? User::where('is_banned', 1)->orderBy('users.name')->paginate(30)->appends($request->query()) : null,
'users' => $canView ? User::where('is_banned', 1)->with('primaryAlias', 'settings')->orderBy('users.name')->paginate(30)->appends($request->query()) : null,
]);
}

Expand All @@ -147,8 +147,8 @@ public function getBlacklist(Request $request) {
* @return \Illuminate\Contracts\Support\Renderable
*/
public function getCharacters(Request $request) {
$query = Character::with('user.rank')->with('image.features')->with('rarity')->with('image.species')->myo(0);
$imageQuery = CharacterImage::images(Auth::check() ? Auth::user() : null)->with('features')->with('rarity')->with('species')->with('features');
$query = Character::with('user.rank', 'image.features', 'rarity', 'image.species', 'image.rarity')->myo(0);
$imageQuery = CharacterImage::images(Auth::check() ? Auth::user() : null)->with('features', 'rarity', 'species', 'features');

if ($sublists = Sublist::where('show_main', 0)->get()) {
$subCategories = [];
Expand Down Expand Up @@ -328,9 +328,9 @@ public function getCharacters(Request $request) {
* @return \Illuminate\Contracts\Support\Renderable
*/
public function getMyos(Request $request) {
$query = Character::with('user.rank')->with('image.features')->with('rarity')->with('image.species')->myo(1);
$query = Character::with('user.rank', 'image.features', 'rarity', 'image.species', 'image.rarity')->myo(1);

$imageQuery = CharacterImage::images(Auth::check() ? Auth::user() : null)->with('features')->with('rarity')->with('species')->with('features');
$imageQuery = CharacterImage::images(Auth::check() ? Auth::user() : null)->with('features', 'rarity', 'species', 'features');

if ($request->get('name')) {
$query->where(function ($query) use ($request) {
Expand Down Expand Up @@ -459,8 +459,8 @@ public function getMyos(Request $request) {
* @return \Illuminate\Contracts\Support\Renderable
*/
public function getSublist(Request $request, $key) {
$query = Character::with('user.rank')->with('image.features')->with('rarity')->with('image.species')->myo(0);
$imageQuery = CharacterImage::with('features')->with('rarity')->with('species')->with('features');
$query = Character::with('user.rank', 'image.features', 'rarity', 'image.species', 'image.rarity')->myo(0);
$imageQuery = CharacterImage::with('features', 'rarity', 'species', 'features');

$sublist = Sublist::where('key', $key)->first();
if (!$sublist) {
Expand Down

0 comments on commit 812a4c6

Please sign in to comment.