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