remove shixuns evaluate count code

pre_develop
p31729568 6 years ago
parent 0d52d5fe4a
commit 15a2f16453

@ -533,7 +533,6 @@ class GamesService
# 更新评测次数 # 更新评测次数
game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1)) game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1))
# shixun.increment!(:evaluate_count)
# 清空代码评测信息 # 清空代码评测信息
msg = game.run_code_message msg = game.run_code_message
msg.update_attributes(:status => 0, :message => nil) if msg.present? msg.update_attributes(:status => 0, :message => nil) if msg.present?
@ -694,7 +693,6 @@ class GamesService
:evaluate_count]).find_by_identifier(params[:identifier]) :evaluate_count]).find_by_identifier(params[:identifier])
# 更新评测次数 # 更新评测次数
game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1)) game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1))
# game.challenge.shixun.increment!(:evaluate_count)
# 选择题如果通关了,则不让再评测 # 选择题如果通关了,则不让再评测
if game.status == 2 if game.status == 2

@ -3,8 +3,9 @@ class Management::SchoolReportService
attr_reader :params attr_reader :params
# 因为实在太慢了,所以不开放 shixun_evaluate_count 排序
sort_columns :student_count, :teacher_count, :homework_count, :other_homework_count, sort_columns :student_count, :teacher_count, :homework_count, :other_homework_count,
:course_count, :active_course_count, :nearly_course_time, :shixun_count, :shixun_evaluate_count, :course_count, :active_course_count, :nearly_course_time, :shixun_count,
default_by: :teacher_count, default_direction: :desc default_by: :teacher_count, default_direction: :desc
def initialize(params) def initialize(params)
@ -49,7 +50,8 @@ class Management::SchoolReportService
shixun_map = Shixun.joins(creator: :user_extensions).where(user_extensions: { identity: User::TEACHER, school_id: ids }) shixun_map = Shixun.joins(creator: :user_extensions).where(user_extensions: { identity: User::TEACHER, school_id: ids })
.group('school_id').count .group('school_id').count
evaluate_count_map = Shixun.joins(creator: :user_extensions).where(user_extensions: { identity: User::TEACHER, school_id: ids }) evaluate_count_map = Game.joins(challenge: { shixun: { creator: :user_extensions } })
.where(user_extensions: { identity: User::TEACHER, school_id: ids })
.group('school_id').sum(:evaluate_count) .group('school_id').sum(:evaluate_count)
schools.map do |school| schools.map do |school|
@ -90,7 +92,9 @@ class Management::SchoolReportService
.select("#{base_query_column}, COUNT(*) shixun_count") .select("#{base_query_column}, COUNT(*) shixun_count")
when 'shixun_evaluate_count' then when 'shixun_evaluate_count' then
schools.joins(teacher_extensions: :user).joins('INNER JOIN shixuns sx ON sx.user_id = users.id') schools.joins(teacher_extensions: :user).joins('INNER JOIN shixuns sx ON sx.user_id = users.id')
.select("#{base_query_column}, SUM(sx.evaluate_count) shixun_evaluate_count") .joins('LEFT JOIN challenges cs ON cs.shixun_id = sx.id')
.joins('LEFT JOIN games ON games.challenge_id = cs.id')
.select("#{base_query_column}, SUM(games.evaluate_count) shixun_evaluate_count")
when 'nearly_course_time' then when 'nearly_course_time' then
schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0') schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0')
.joins('LEFT JOIN course_activities acs ON acs.course_id = cs.id') .joins('LEFT JOIN course_activities acs ON acs.course_id = cs.id')

@ -10,7 +10,8 @@
<th width="10%"><%= sort_tag('课堂总数', name: 'course_count', path: school_report_managements_path) %></th> <th width="10%"><%= sort_tag('课堂总数', name: 'course_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('正在进行课堂数', name: 'active_course_count', path: school_report_managements_path) %></th> <th width="10%"><%= sort_tag('正在进行课堂数', name: 'active_course_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('创建实训数', name: 'shixun_count', path: school_report_managements_path) %></th> <th width="10%"><%= sort_tag('创建实训数', name: 'shixun_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('评测次数', name: 'shixun_evaluate_count', path: school_report_managements_path) %></th> <!-- <th width="10%"><%#= sort_tag('评测次数', name: 'shixun_evaluate_count', path: school_report_managements_path) %></th>-->
<th width="10%">评测次数</th>
<th width="10%"><%= sort_tag('实训作业总数', name: 'homework_count', path: school_report_managements_path) %></th> <th width="10%"><%= sort_tag('实训作业总数', name: 'homework_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('其它作业总数', name: 'other_homework_count', path: school_report_managements_path) %></th> <th width="10%"><%= sort_tag('其它作业总数', name: 'other_homework_count', path: school_report_managements_path) %></th>
<th width="14%"><%= sort_tag('动态时间', name: 'nearly_course_time', path: school_report_managements_path) %></th> <th width="14%"><%= sort_tag('动态时间', name: 'nearly_course_time', path: school_report_managements_path) %></th>

@ -0,0 +1,9 @@
class RemoveEvaluateCountFromShixuns < ActiveRecord::Migration
def up
remove_column :shixuns, :evaluate_count
end
def down
add_column :shixuns, :evaluate_count, :integer, default: 0
end
end
Loading…
Cancel
Save