讨论区的调整

dev_forge
cxt 5 years ago
parent 0b3e469275
commit 09da308c99

@ -20,7 +20,12 @@ class MessagesController < ApplicationController
sort = params[:sort].to_i == 1 ? 'asc' : 'desc'
sort_type = params[:sort_type] || 'time'
messages = @board.messages.root_nodes.by_keywords(params[:search])
if @board.parent_id == 0
messages = Message.where(board_id: @course.boards.pluck(:id))
else
messages = @board.messages
end
messages = messages.root_nodes.by_keywords(params[:search])
messages = messages.reorder('(sticky = 1) DESC') # 置顶

@ -8,7 +8,7 @@ json.data do
json.array! @messages do |message|
json.extract! message, :id, :parent_id, :subject, :created_on, :total_replies_count,
:praises_count, :visits, :sticky, :is_hidden, :is_public, :board_id
json.category_name message.board&.name
json.category_name message.board&.name if @board.parent_id == 0 && message.board_id != @board.id
json.total_praises_count @praises_count_map.fetch(message.id, 0)

Loading…
Cancel
Save