Skip to content

Commit

Permalink
Update StoryController, fix postgres bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dansup committed Jan 15, 2020
1 parent b0fd75f commit 8360aa4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/Http/Controllers/StoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ public function apiV1Recent(Request $request)

$profile = $request->user()->profile;
$following = $profile->following->pluck('id')->toArray();
$groupBy = config('database.default') == 'pgsql' ? 'id' : 'profile_id';

$stories = Story::with('profile')
->whereIn('profile_id', $following)
->where('expires_at', '>', now())
->groupBy('profile_id')
->groupBy($groupBy)
->orderByDesc('expires_at')
->take(9)
->get()
Expand Down

0 comments on commit 8360aa4

Please sign in to comment.