adminx: fix user statistic

problem_set
p31729568 5 years ago
parent 5fe5bab9a4
commit f0c2c71e5d

@ -36,8 +36,8 @@ class Admins::UserStatisticQuery < ApplicationQuery
study_myshixun = Myshixun.where(user_id: ids)
finish_myshixun = Myshixun.where(user_id: ids, status: 1)
study_challenge = Game.joins(:myshixun).where(myshixuns: { user_id: ids }).where(status: [0, 1, 2])
finish_challenge = Game.joins(:myshixun).where(myshixuns: { user_id: ids }).where(status: 2)
study_challenge = Game.where(user_id: ids).where(status: [0, 1, 2])
finish_challenge = Game.where(user_id: ids).where(status: 2)
if time_range.present?
study_myshixun = study_myshixun.where(updated_at: time_range)
@ -106,12 +106,12 @@ class Admins::UserStatisticQuery < ApplicationQuery
when 'finish_challenge_count' then
users =
if time_range.present?
users.joins('LEFT JOIN myshixuns ON myshixuns.user_id = users.id')
.joins("LEFT JOIN games ON games.myshixun_id = myshixuns.id "\
users#.joins('LEFT JOIN myshixuns ON myshixuns.user_id = users.id')
.joins("LEFT JOIN games ON games.user_id = users.id "\
"AND games.status = 2 AND games.updated_at BETWEEN '#{time_range.min}' AND '#{time_range.max}'")
else
users.joins('LEFT JOIN myshixuns ON myshixuns.user_id = users.id')
.joins("LEFT JOIN games ON games.myshixun_id = myshixuns.id AND games.status = 2")
users#.joins('LEFT JOIN myshixuns ON myshixuns.user_id = users.id')
.joins("LEFT JOIN games ON games.user_id = users.id AND games.status = 2")
end
users.select("#{base_query_column}, COUNT(*) finish_challenge_count")

Loading…
Cancel
Save