mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-28 13:31:06 +00:00
Fixes forum topic ordering by latest post
This commit is contained in:
parent
5900a6602f
commit
d40e0e4c46
1 changed files with 3 additions and 2 deletions
|
@ -11,9 +11,10 @@ class ForumsController < ApplicationController
|
||||||
raise AccessError unless @forum.can_show? cuser
|
raise AccessError unless @forum.can_show? cuser
|
||||||
|
|
||||||
@topics = Topic.where(forum_id: @forum.id)
|
@topics = Topic.where(forum_id: @forum.id)
|
||||||
.includes(:posts, :user, :users_who_read, :lock)
|
.joins(posts: :user)
|
||||||
|
.includes(:lock, :readings)
|
||||||
.group('topics.id')
|
.group('topics.id')
|
||||||
.order('state DESC, posts.id DESC')
|
.order('state DESC, (SELECT created_at FROM posts p2 WHERE p2.topic_id = topics.id ORDER BY created_at DESC LIMIT 1) DESC')
|
||||||
.paginate(page: params[:page], per_page: 30)
|
.paginate(page: params[:page], per_page: 30)
|
||||||
|
|
||||||
@forum.read_by! cuser if cuser
|
@forum.read_by! cuser if cuser
|
||||||
|
|
Loading…
Reference in a new issue