From f0c2c71e5d4530fc478ec5638e5b372d3f8e0acc Mon Sep 17 00:00:00 2001 From: p31729568 Date: Tue, 22 Oct 2019 17:22:23 +0800 Subject: [PATCH] adminx: fix user statistic --- app/queries/admins/user_statistic_query.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/queries/admins/user_statistic_query.rb b/app/queries/admins/user_statistic_query.rb index d05656b3e..9f8fed952 100644 --- a/app/queries/admins/user_statistic_query.rb +++ b/app/queries/admins/user_statistic_query.rb @@ -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")