Merge branch 'develop' into dev_aliyun

dev_auth
cxt 5 years ago
commit e9265e650e

@ -22,7 +22,7 @@ class Competitions::CompetitionsController < Competitions::BaseController
@count = competitions.count @count = competitions.count
competitions = competitions.order(published_at: :desc, online_time: :desc) competitions = competitions.order(published_at: :desc, online_time: :desc)
@competitions = paginate(competitions.includes(sponsor_schools: :school, current_stage_section: :competition_stage)) @competitions = paginate(competitions.includes(:competition_mode_setting, sponsor_schools: :school, current_stage_section: :competition_stage))
ids = @competitions.map(&:id) ids = @competitions.map(&:id)
@member_count_map = TeamMember.where(competition_id: ids).group(:competition_id).count @member_count_map = TeamMember.where(competition_id: ids).group(:competition_id).count

@ -125,7 +125,7 @@ class HomeworkCommonsController < ApplicationController
# 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段 # 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段
if @work&.work_status.to_i > 0 && (@homework.work_public || @homework.score_open) && if @work&.work_status.to_i > 0 && (@homework.work_public || @homework.score_open) &&
((!@homework.anonymous_comment && @homework.end_or_late) || (@homework_detail_manual.comment_status > 4 && @homework.end_or_late)) ((!@homework.anonymous_comment && @homework.end_or_late) || (@homework_detail_manual.comment_status > 4 && @homework.end_or_late))
@student_works = student_works.where("user_id != #{@work.user_id}") @student_works = student_works.where("student_works.user_id != #{@work.user_id}")
# 匿评、申诉阶段只能看到分配给自己的匿评作品 # 匿评、申诉阶段只能看到分配给自己的匿评作品
elsif @work&.work_status.to_i > 0 && @homework.anonymous_comment && @homework_detail_manual.comment_status > 2 && @homework_detail_manual.comment_status <= 4 elsif @work&.work_status.to_i > 0 && @homework.anonymous_comment && @homework_detail_manual.comment_status > 2 && @homework_detail_manual.comment_status <= 4

@ -49,6 +49,12 @@ class Competition < ApplicationRecord
end end
end end
# 报名数
def team_member_count
course = competition_mode_setting&.course if mode == 2
course ? course.students.count : team_members.count
end
def sponsor_schools_name def sponsor_schools_name
sponsor_schools.map{|sponsor| sponsor.school.name} sponsor_schools.map{|sponsor| sponsor.school.name}
end end

@ -1,6 +1,6 @@
json.extract! @competition, :id, :name, :sub_title, :identifier, :bonus, :mode json.extract! @competition, :id, :name, :sub_title, :identifier, :bonus, :mode
json.visits_count @competition.visits json.visits_count @competition.visits
member_count = @competition.team_members.count member_count = @competition.team_member_count
json.member_count member_count.zero? ? 268 : member_count json.member_count member_count.zero? ? 268 : member_count
json.start_time @competition.start_time&.strftime("%Y-%m-%d") json.start_time @competition.start_time&.strftime("%Y-%m-%d")

@ -5,7 +5,8 @@ json.competitions do
json.competition_status competition.competition_status json.competition_status competition.competition_status
json.visits_count competition.visits json.visits_count competition.visits
member_count = @member_count_map&.fetch(competition.id, 0) || competition.team_members.count course = competition.competition_mode_setting&.course if competition.mode == 2
member_count = course ? course.students.count : (@member_count_map&.fetch(competition.id, 0) || competition.team_members.count)
json.member_count member_count.zero? ? 268 : member_count json.member_count member_count.zero? ? 268 : member_count
json.image url_to_avatar(competition) json.image url_to_avatar(competition)

@ -1,7 +1,7 @@
json.course_members @course_members.each do |member| json.course_members @course_members.each do |member|
user = member.user user = User.find_by(id: member.user_id)
json.user_login user.login json.user_login user&.login
json.user_name user.real_name json.user_name user&.real_name
# json.course_group member.course_group_name # json.course_group member.course_group_name
json.total_score member.score json.total_score member.score
end end
Loading…
Cancel
Save