|
|
|
@ -2,7 +2,7 @@ class Schools::SchoolStatisticService < ApplicationService
|
|
|
|
|
attr_reader :school
|
|
|
|
|
|
|
|
|
|
def initialize(school)
|
|
|
|
|
@school = school.includes(:courses, user_extensions: :user)
|
|
|
|
|
@school = school
|
|
|
|
|
@user_extensions = school.user_extensions
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -26,14 +26,14 @@ class Schools::SchoolStatisticService < ApplicationService
|
|
|
|
|
@user_extensions.map{|ue| ue.user.last_login_on&.between?(1.weeks.ago, Time.now)}.size
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 活跃用户(近3个月有登录)
|
|
|
|
|
# 活跃用户(近1个月有登录)
|
|
|
|
|
def acitve_user_1_months_count
|
|
|
|
|
@user_extensions.map{|ue| ue.user.last_login_on&.between?(1.months.ago, Time.now)}.size
|
|
|
|
|
@user_extensions.joins(:user).map{|ue| ue.user.last_login_on&.between?(1.months.ago, Time.now)}.size
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 活跃用户(近3个月有登录)
|
|
|
|
|
def acitve_user_3_months_count
|
|
|
|
|
@user_extensions.map{|ue| ue.user.last_login_on&.between?(3.months.ago, Time.now)}.size
|
|
|
|
|
@user_extensions.map{|ue| ue.user&.last_login_on&.between?(3.months.ago, Time.now)}.size
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 活跃用户(进半年有登录记录)
|
|
|
|
@ -52,10 +52,15 @@ class Schools::SchoolStatisticService < ApplicationService
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 实训作业数目
|
|
|
|
|
def hom_shixuns_count
|
|
|
|
|
def homw_shixuns_count
|
|
|
|
|
@school.courses.joins(:homework_commons).where(homework_commons: {homework_type: 'practice'}).size
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 其他类型作业
|
|
|
|
|
def homw_other_count
|
|
|
|
|
@school.courses.joins(:homework_commons).where.not(homework_commons: {homework_type: 'practice'}).size
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 资源数
|
|
|
|
|
def sources_count
|
|
|
|
|
@school.courses.joins(:attachments).size
|
|
|
|
@ -67,7 +72,7 @@ class Schools::SchoolStatisticService < ApplicationService
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 制作实训数
|
|
|
|
|
def shixun_count
|
|
|
|
|
def shixuns_count
|
|
|
|
|
@user_extensions.joins(user: :shixuns).size
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -83,17 +88,17 @@ class Schools::SchoolStatisticService < ApplicationService
|
|
|
|
|
|
|
|
|
|
# 挑战的关卡数
|
|
|
|
|
def games_count
|
|
|
|
|
@user_extensions.joins("join games on games.user_id = user_extensions.user_id").where(games: {status: 0..2})
|
|
|
|
|
@user_extensions.joins("join games on games.user_id = user_extensions.user_id").where(games: {status: 0..2}).size
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 通关的关卡数
|
|
|
|
|
def pass_games_count
|
|
|
|
|
@user_extensions.joins("join games on games.user_id = user_extensions.user_id").where(games: {status: 2})
|
|
|
|
|
@user_extensions.joins("join games on games.user_id = user_extensions.user_id").where(games: {status: 2}).size
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 评测总数
|
|
|
|
|
def evalute_count
|
|
|
|
|
@user_extensions.joins("join games on games.user_id = user_extensions.user_id").sum(:evalute_count)
|
|
|
|
|
def evaluate_count
|
|
|
|
|
@user_extensions.joins("join games on games.user_id = user_extensions.user_id").sum(:evaluate_count).to_i
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|