|
|
@ -9,15 +9,18 @@ class DiscussesController < ApplicationController
|
|
|
|
# 总数,分页使用
|
|
|
|
# 总数,分页使用
|
|
|
|
if current_user.admin?
|
|
|
|
if current_user.admin?
|
|
|
|
@disscuss_count = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).count
|
|
|
|
@disscuss_count = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).count
|
|
|
|
@discusses = Discuss.limit(LIMIT).where(:dis_id => @container.id, :dis_type => @container.class.to_s,
|
|
|
|
disscusses = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s,
|
|
|
|
:root_id => nil).includes(:user, :praise_treads).offset(offset)
|
|
|
|
:root_id => nil).joins(challenge: :games)
|
|
|
|
|
|
|
|
.where("discusses.user_id = games.user_id").select("discusses.*, games.identifier")
|
|
|
|
else
|
|
|
|
else
|
|
|
|
disscusses = Discuss.where("dis_id = :dis_id and dis_type = :dis_type and root_id is null and
|
|
|
|
disscusses = Discuss.where("dis_id = :dis_id and dis_type = :dis_type and root_id is null and
|
|
|
|
(hidden = :hidden or user_id = :user_id)",
|
|
|
|
(hidden = :hidden or user_id = :user_id)",
|
|
|
|
{dis_id: @container.id, dis_type: @container.class.to_s, hidden: false, user_id: current_user.id})
|
|
|
|
{dis_id: @container.id, dis_type: @container.class.to_s, hidden: false, user_id: current_user.id})
|
|
|
|
|
|
|
|
.joins(challenge: :games).where("discusses.user_id = games.user_id").select("discusses.*, games.identifier")
|
|
|
|
@disscuss_count = disscusses.count
|
|
|
|
@disscuss_count = disscusses.count
|
|
|
|
@discusses = disscusses.limit(LIMIT).includes(:user, :praise_treads).offset(offset)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@discusses = disscusses.limit(LIMIT).includes(:user, :praise_treads).offset(offset)
|
|
|
|
|
|
|
|
@manger = @container.has_manager?(current_user)
|
|
|
|
|
|
|
|
|
|
|
|
@current_user = current_user
|
|
|
|
@current_user = current_user
|
|
|
|
end
|
|
|
|
end
|
|
|
|