|
|
|
@ -82,16 +82,9 @@ class Subject < ApplicationRecord
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def my_subject_progress
|
|
|
|
|
logger.info("#-----------")
|
|
|
|
|
my_challenge_count = Game.joins(:challenge).where(user_id: User.current.id, status: 2, challenges: {shixun_id: shixuns.published_closed}).
|
|
|
|
|
pluck(:challenge_id).uniq.size
|
|
|
|
|
logger.info("#-----------")
|
|
|
|
|
new_challenge_count = Challenge.left_joins(:games)
|
|
|
|
|
.where(games: {user_id: User.current.id, status: 2}, shixun_id: shixuns.published_closed)
|
|
|
|
|
.uniq.count
|
|
|
|
|
logger.info("#-----------")
|
|
|
|
|
subject_challenge_count = shixuns.sum(:challenges_count)
|
|
|
|
|
subject_challenge_count == 0 ? 0 : ((my_challenge_count.to_f / subject_challenge_count).round(2) * 100).to_i
|
|
|
|
|
pluck(:challenge_id).uniq.size
|
|
|
|
|
count = self.subject_challenge_count == 0 ? 0 : ((my_challenge_count.to_f / self.subject_challenge_count).round(2) * 100).to_i
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def my_consume_time
|
|
|
|
|