dev_aliyun
p31729568 5 years ago
parent 6822506bdf
commit be11a48ea8

@ -25,11 +25,12 @@ class CompetitionTeamsController < ApplicationController
shixun_ids = @shixuns.map(&:id) shixun_ids = @shixuns.map(&:id)
@myshixun_count_map = get_valid_myshixun_count(shixun_ids) @myshixun_count_map = get_valid_myshixun_count(shixun_ids)
@original_myshixun_count_map = @myshixun_count_map.clone
# forked shixun valid myshixun count # forked shixun valid myshixun count
forked_shixun_map = Shixun.where(status: 2, fork_from: shixun_ids).select('id, fork_from') forked_shixun_map = Shixun.where(status: 2, fork_from: shixun_ids).select('id, fork_from')
forked_shixun_map = forked_shixun_map.each_with_object({}) { |sx, obj| obj[sx.id] = sx.fork_from } forked_shixun_map = forked_shixun_map.each_with_object({}) { |sx, obj| obj[sx.id] = sx.fork_from }
forked_myshixun_count_map = get_valid_myshixun_count(forked_shixun_map.keys) @forked_myshixun_count_map = get_valid_myshixun_count(forked_shixun_map.keys)
forked_myshixun_count_map.each { |k, v| @myshixun_count_map[forked_shixun_map[k]] += v } @forked_myshixun_count_map.each { |k, v| @myshixun_count_map[forked_shixun_map[k]] += v }
@course_count_map = get_valid_course_count(shixun_ids) @course_count_map = get_valid_course_count(shixun_ids)
forked_map = get_valid_course_count(forked_shixun_map.keys) forked_map = get_valid_course_count(forked_shixun_map.keys)
@ -38,6 +39,7 @@ class CompetitionTeamsController < ApplicationController
@forked_course_count_map[forked_shixun_map[forked_id]] ||= 0 @forked_course_count_map[forked_shixun_map[forked_id]] ||= 0
@forked_course_count_map[forked_shixun_map[forked_id]] += course_count @forked_course_count_map[forked_shixun_map[forked_id]] += course_count
end end
@forked_shixun_map = forked_shixun_map
# 课堂 # 课堂

@ -28,14 +28,20 @@
total_forked_myshixun_count += shixun['forked_myshixun_count'].to_i total_forked_myshixun_count += shixun['forked_myshixun_count'].to_i
valid_course_count = @course_count_map.fetch(shixun.id, 0) valid_course_count = @course_count_map.fetch(shixun.id, 0)
valid_student_count = @myshixun_count_map.fetch(shixun.id, 0) valid_student_count = @original_myshixun_count_map.fetch(shixun.id, 0)
score = score =
if shixun.fork_from.blank? if shixun.fork_from.blank?
500 + 50 * valid_course_count + 10 * valid_student_count 500 + 50 * valid_course_count + 10 * valid_student_count
else else
100 + 10 * valid_course_count + 5 * valid_student_count 100 + 10 * valid_course_count + 5 * valid_student_count
end end
score += @forked_course_count_map.fetch(shixun.id, 0)
@forked_shixun_map.each do |shixun_id, fork_from_id|
next if fork_from_id != shixun.id
score += 100 + 10 * @forked_shixun_map.fetch(shixun_id, 0) + 5 * @forked_myshixun_count_map.fetch(shixun_id, 0)
end
total_shixun_score += score total_shixun_score += score
%> %>
<tr> <tr>

Loading…
Cancel
Save