From 1fa703cf81b6c1026452d0fa156d3a699072a724 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 31 Oct 2019 16:39:03 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E7=9A=84=E7=AB=9E=E8=B5=9B=E6=8A=A5=E5=90=8D=E6=95=B0=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=9C=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/competitions/competitions_controller.rb | 2 +- app/views/competitions/competitions/index.json.jbuilder | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/competitions/competitions_controller.rb b/app/controllers/competitions/competitions_controller.rb index 1a80dc7e6..31ed4367d 100644 --- a/app/controllers/competitions/competitions_controller.rb +++ b/app/controllers/competitions/competitions_controller.rb @@ -22,7 +22,7 @@ class Competitions::CompetitionsController < Competitions::BaseController @count = competitions.count 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) @member_count_map = TeamMember.where(competition_id: ids).group(:competition_id).count diff --git a/app/views/competitions/competitions/index.json.jbuilder b/app/views/competitions/competitions/index.json.jbuilder index c01f0aa59..5027cdee0 100644 --- a/app/views/competitions/competitions/index.json.jbuilder +++ b/app/views/competitions/competitions/index.json.jbuilder @@ -5,7 +5,8 @@ json.competitions do json.competition_status competition.competition_status 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.image url_to_avatar(competition) From 10d3b3f5c124b85ec05ad58d8fb02c49acbb3b42 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 31 Oct 2019 16:47:43 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/competition.rb | 6 ++++++ .../competitions/competitions/common_header.json.jbuilder | 2 +- app/views/competitions/competitions/index.json.jbuilder | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/competition.rb b/app/models/competition.rb index 9eac28616..cd26088dd 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -46,6 +46,12 @@ class Competition < ApplicationRecord 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 sponsor_schools.map{|sponsor| sponsor.school.name} end diff --git a/app/views/competitions/competitions/common_header.json.jbuilder b/app/views/competitions/competitions/common_header.json.jbuilder index a869d920b..0d0f3f4ca 100644 --- a/app/views/competitions/competitions/common_header.json.jbuilder +++ b/app/views/competitions/competitions/common_header.json.jbuilder @@ -1,6 +1,6 @@ json.extract! @competition, :id, :name, :sub_title, :identifier, :bonus, :mode 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.start_time @competition.start_time&.strftime("%Y-%m-%d") diff --git a/app/views/competitions/competitions/index.json.jbuilder b/app/views/competitions/competitions/index.json.jbuilder index 5027cdee0..b7a3f20e0 100644 --- a/app/views/competitions/competitions/index.json.jbuilder +++ b/app/views/competitions/competitions/index.json.jbuilder @@ -5,7 +5,7 @@ json.competitions do json.competition_status competition.competition_status json.visits_count competition.visits - course = competition.competition_mode_setting.course if competition.mode == 2 + 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 From 5ec53d0961cb6cb09969b4dcc32ab58f1c34087a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 31 Oct 2019 18:11:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 5d27de7b8..2bb8ec6cf 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -125,7 +125,7 @@ class HomeworkCommonsController < ApplicationController # 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段 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)) - @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 From d00402730fff85171de6399529bd11d2f4d5acd2 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 1 Nov 2019 10:09:58 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/act_score.json.jbuilder | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/courses/act_score.json.jbuilder b/app/views/courses/act_score.json.jbuilder index 394497635..064b13f03 100644 --- a/app/views/courses/act_score.json.jbuilder +++ b/app/views/courses/act_score.json.jbuilder @@ -1,7 +1,7 @@ json.course_members @course_members.each do |member| - user = member.user - json.user_login user.login - json.user_name user.real_name + user = User.find_by(id: member.user_id) + json.user_login user&.login + json.user_name user&.real_name # json.course_group member.course_group_name json.total_score member.score end \ No newline at end of file