You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.4 KiB
41 lines
1.4 KiB
total_myshixun_count = 0
|
|
total_forked_myshixun_count = 0
|
|
total_shixun_score = 0
|
|
|
|
json.shixuns @shixuns.each do |shixun|
|
|
total_myshixun_count += shixun.myshixuns_count
|
|
total_forked_myshixun_count += shixun['forked_myshixun_count'].to_i
|
|
|
|
valid_course_count = @course_count_map.fetch(shixun.id, 0)
|
|
valid_student_count = @original_myshixun_count_map.fetch(shixun.id, 0)
|
|
score =
|
|
if shixun.fork_from.blank?
|
|
500 + 50 * valid_course_count + 10 * valid_student_count
|
|
else
|
|
100 + 10 * valid_course_count + 5 * valid_student_count
|
|
end
|
|
|
|
@forked_shixun_map.each do |shixun_id, fork_from_id|
|
|
next if fork_from_id != shixun.id
|
|
|
|
score += 100 + 10 * @forked_map.fetch(shixun_id, 0) + 5 * @forked_myshixun_count_map.fetch(shixun_id, 0)
|
|
end
|
|
|
|
total_shixun_score += score
|
|
|
|
json.creator shixun.user.real_name
|
|
json.creator_login shixun.user.login
|
|
json.shixun_name shixun.name
|
|
json.shixun_identifier shixun.identifier
|
|
json.forked shixun.fork_from.present?
|
|
json.myshixuns_count shixun.myshixuns_count
|
|
json.forked_myshixun_count shixun['forked_myshixun_count'].to_i
|
|
json.valid_count @myshixun_count_map.fetch(shixun.id, 0)
|
|
json.score score
|
|
end
|
|
|
|
json.shixun_count @shixuns.size
|
|
json.total_myshixun_count total_myshixun_count
|
|
json.total_forked_myshixun_count total_forked_myshixun_count
|
|
json.total_valid_count @myshixun_count_map.values.reduce(:+)
|
|
json.total_shixun_score total_shixun_score |