diff --git a/app/services/management/school_data_grow_service.rb b/app/services/management/school_data_grow_service.rb index 470a3367..815f642c 100644 --- a/app/services/management/school_data_grow_service.rb +++ b/app/services/management/school_data_grow_service.rb @@ -70,15 +70,16 @@ class Management::SchoolDataGrowService end def joins_school_daily_report_sql - SchoolDailyReport.joins('LEFT JOIN school_daily_active_users au ON au.school_daily_report_id = school_daily_reports.id') + subquery = 'select COUNT(distinct user_id) from school_daily_active_users sdau where sdau.school_daily_report_id = school_daily_reports.id' + SchoolDailyReport .select('school_id, '\ - 'SUM(distinct teacher_increase_count) teacher_increase_count,'\ - 'SUM(distinct student_increase_count) student_increase_count,'\ - 'SUM(distinct course_increase_count) course_increase_count,'\ - 'SUM(distinct shixun_increase_count) shixun_increase_count,'\ - 'SUM(distinct shixun_homework_count) shixun_homework_count,'\ - 'SUM(distinct shixun_evaluate_count) shixun_evaluate_count,'\ - 'COUNT(distinct au.user_id) uniq_active_user_count,'\ + 'SUM(teacher_increase_count) teacher_increase_count,'\ + 'SUM(student_increase_count) student_increase_count,'\ + 'SUM(course_increase_count) course_increase_count,'\ + 'SUM(shixun_increase_count) shixun_increase_count,'\ + 'SUM(shixun_homework_count) shixun_homework_count,'\ + 'SUM(shixun_evaluate_count) shixun_evaluate_count,'\ + "(#{subquery}) uniq_active_user_count,"\ 'SUM(distinct active_user_count) active_user_count') .where(date_condition_sql).group(:school_id).to_sql end diff --git a/app/views/managements/schools/_data_grow_list.html.erb b/app/views/managements/schools/_data_grow_list.html.erb index c69ca60b..3c672324 100644 --- a/app/views/managements/schools/_data_grow_list.html.erb +++ b/app/views/managements/schools/_data_grow_list.html.erb @@ -1,7 +1,12 @@
统计总计: <% if params[:grow_begin_date].present? %> - <%= params[:grow_date_input] %> + <% if params[:grow_begin_date] == params[:grow_end_date] %> + <%= Time.zone.parse(params[:grow_begin_date]).beginning_of_day.strftime('%Y-%m-%d') %> 05:00至 + <%= (Time.zone.parse(params[:grow_begin_date]).beginning_of_day + 1.days).strftime('%Y-%m-%d') %> 05:00 + <% else %> + <%= params[:grow_begin_date] %> 05:00至<%= params[:grow_end_date] %> 05:00 + <% end %> <% else %> <%= (Time.current - 5.hour).beginning_of_day.ago(1.days).strftime('%Y-%m-%d') %> 05:00至 <%= (Time.current - 5.hour).beginning_of_day.strftime('%Y-%m-%d') %> 05:00,