Skip to content

Commit

Permalink
Order by MAX visisted_at
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBelgium committed Sep 17, 2021
1 parent 7347d2b commit a8a56a4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
})->relationship(DV_RELATIONSHIP_LATEST, function (AbstractModel $model) use ($settings) {
return $model->views()->limit($settings->get('michaelbelgium-discussionviews.max_listcount', 5));
})->relationship(DV_RELATIONSHIP_UNIQUE, function (AbstractModel $model) use ($settings) {
return $model->views()->groupBy('user_id')->havingRaw('user_id IS NOT NULL')->limit($settings->get('michaelbelgium-discussionviews.max_listcount', 5));
return $model->views()->groupBy('user_id')->havingRaw('user_id IS NOT NULL')->orderByRaw('MAX(visited_at) DESC')
->limit($settings->get('michaelbelgium-discussionviews.max_listcount', 5));
}),

(new Settings)
Expand Down

0 comments on commit a8a56a4

Please sign in to comment.