Skip to content

Commit

Permalink
improved pagespeed
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu committed May 30, 2020
1 parent ed7b489 commit 7293a0c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions app/Http/Controllers/CrowdsourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct()
*/
public function renderRewe()
{
$categories = ReweProductCategory::where('parent_id', '<>', null)->get();
$categories = ReweProductCategory::with(['parent'])->where('parent_id', '<>', null)->get();

$nextProductAtCategory = ReweProduct::join('rewe_bon_positions', 'rewe_bon_positions.product_id', '=', 'rewe_products.id')
->join('rewe_bons', 'rewe_bon_positions.bon_id', '=', 'rewe_bons.id')
Expand All @@ -45,7 +45,7 @@ public function renderRewe()
->limit(1)
->first();

$lastCategories = ReweCrowdsourcingCategory::where('user_id', auth()->user()->id)->orderByDesc('created_at')->limit(7)->get();
$lastCategories = ReweCrowdsourcingCategory::with(['category', 'product'])->where('user_id', auth()->user()->id)->orderByDesc('created_at')->limit(7)->get();


$nextProductAtVegetarian = ReweProduct::join('rewe_bon_positions', 'rewe_bon_positions.product_id', '=', 'rewe_products.id')
Expand All @@ -63,7 +63,7 @@ public function renderRewe()
->first();


$lastVegetarians = ReweCrowdsourcingVegetarian::where('user_id', auth()->user()->id)->orderByDesc('created_at')->limit(7)->get();
$lastVegetarians = ReweCrowdsourcingVegetarian::with(['product'])->where('user_id', auth()->user()->id)->orderByDesc('created_at')->limit(7)->get();

return view('crowdsourcing.rewe', [
'categories' => $categories,
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ReweController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function index()

$bonList = ReweBon::where('user_id', auth()->user()->id)->orderByDesc('timestamp_bon')->get();

$shops = ReweBon::where('user_id', auth()->user()->id)
$shops = ReweBon::with(['shop'])->where('user_id', auth()->user()->id)
->groupBy('shop_id')
->select('shop_id', DB::raw('COUNT(*) as cnt'))
->orderBy(DB::raw('COUNT(*)'), 'desc')
Expand Down
9 changes: 6 additions & 3 deletions app/Http/Controllers/SpotifyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ public function index()
->limit(1)
->first();

$topTracksTotal = SpotifyPlayActivity::where('user_id', auth()->user()->id)
$topTracksTotal = SpotifyPlayActivity::with(['track', 'track.album', 'track.artists'])
->where('user_id', auth()->user()->id)
->groupBy('track_id')
->select('track_id', DB::raw('COUNT(*) as minutes'))
->orderBy('minutes', 'DESC')
->limit(3)
->get();

$topTracks30d = SpotifyPlayActivity::where('user_id', auth()->user()->id)
$topTracks30d = SpotifyPlayActivity::with(['track', 'track.album', 'track.artists'])
->where('user_id', auth()->user()->id)
->where('created_at', '>', DB::raw('(NOW() - INTERVAL 30 DAY)'))
->groupBy('track_id')
->select('track_id', DB::raw('COUNT(*) as minutes'))
Expand Down Expand Up @@ -274,7 +276,8 @@ public static function getLikedAndNotHearedTracks(int $user_id, int $limit = 30,
if ($t1 == $t2 && !in_array($t1, $trackList) && count($trackList) < $limit)
$trackList[] = $t1;

return SpotifyTrack::whereIn('track_id', $trackList)
return SpotifyTrack::with(['artists', 'album'])
->whereIn('track_id', $trackList)
->orderBy('popularity', 'desc')
->limit(UserSettings::get($user_id, 'spotify_oldPlaylist_songlimit', 99))
->get();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/TwitterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static function index()
return view('twitter.notconnected');

return view('twitter.overview', [
'twitter_profile' => $user->socialProfile->twitterUser,
'twitter_profile' => TwitterProfile::with(['unfollower.unfollower_profile'])->where('id', $user->socialProfile->twitter_id)->first(),
]);
}

Expand Down

0 comments on commit 7293a0c

Please sign in to comment.