|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
class Management::SchoolDataGrowService
|
|
|
|
|
include CustomSortable
|
|
|
|
|
|
|
|
|
|
PAGE_SIZE = 20
|
|
|
|
|
|
|
|
|
|
attr_reader :params
|
|
|
|
|
|
|
|
|
|
sort_columns :teacher_increase_count, :student_increase_count,
|
|
|
|
@ -12,7 +14,23 @@ class Management::SchoolDataGrowService
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def call
|
|
|
|
|
custom_sort(query_reports, params[:sort_by], params[:sort_direction])
|
|
|
|
|
reports = query_reports.group(:school_id)
|
|
|
|
|
|
|
|
|
|
count = reports.count.count
|
|
|
|
|
|
|
|
|
|
reports = reports.select(
|
|
|
|
|
'school_id, school_name,'\
|
|
|
|
|
'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(active_user_count) active_user_count'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
reports = custom_sort(reports, params[:sort_by], params[:sort_direction])
|
|
|
|
|
reports = reports.limit(PAGE_SIZE).offset(offset)
|
|
|
|
|
|
|
|
|
|
[count, reports]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def grow_summary
|
|
|
|
@ -56,4 +74,8 @@ class Management::SchoolDataGrowService
|
|
|
|
|
# 每日凌晨5点为节点, 25日凌晨4点、3点、2点等等,未到更新数据时间点,看到的数据是:23日-24日的统计数据
|
|
|
|
|
(Time.zone.now - 5.hours).beginning_of_day - 1.days
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def offset
|
|
|
|
|
(params[:page].to_i.zero? ? 0 : params[:page].to_i - 1) * PAGE_SIZE
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|