课程数据统计

video_transcode
daiao 5 years ago
parent 294aca2771
commit 1a0f966ce8

@ -0,0 +1,100 @@
class Schools::SchoolStatisticService < ApplicationService
attr_reader :school
def initialize(school)
@school = school.includes(:courses, user_extensions: :user)
@user_extensions = school.user_extensions
end
# 学校老师数量
def teacher_count
@user_extensions.map{|ue| ue.identity == 0 }.size
end
# 学校学生数
def student_count
@user_extensions.map{|ue| ue.identity == 1 }.size
end
# 活跃用户近1天有登录
def acitve_user_1_day_count
@user_extensions.map{|ue| ue.user.last_login_on&.between?(1.days.ago, Time.now)}.size
end
# 活跃用户近1个周有登录
def acitve_user_1_week_count
@user_extensions.map{|ue| ue.user.last_login_on&.between?(1.weeks.ago, Time.now)}.size
end
# 活跃用户近3个月有登录
def acitve_user_1_months_count
@user_extensions.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
end
# 活跃用户(进半年有登录记录)
def acitve_user_6_months_count
@user_extensions.map{|ue| ue.user.last_login_on&.between?(6.months.ago, Time.now)}.size
end
# 课堂总数(上层记得Include)
def courses_count
@school.courses.size
end
# 正在进行的课堂数
def curr_courses_count
@school.courses.map{|c| c.is_end == false && c.is_delete != 0}.size
end
# 实训作业数目
def hom_shixuns_count
@school.courses.joins(:homework_commons).where(homework_commons: {homework_type: 'practice'}).size
end
# 资源数
def sources_count
@school.courses.joins(:attachments).size
end
# 视频总数
def videos_count
@school.courses.joins(:course_videos).size
end
# 制作实训数
def shixun_count
@user_extensions.joins(user: :shixuns).size
end
# 挑战实训总数
def myshixuns_count
@user_extensions.joins("join myshixuns on myshixuns.user_id = user_extensions.user_id").size
end
# 通过的实训总数
def pass_myshixun_count
@user_extensions.joins("join myshixuns on myshixuns.user_id = user_extensions.user_id").where(myshixuns: {status: 1}).size
end
# 挑战的关卡数
def games_count
@user_extensions.joins("join games on games.user_id = user_extensions.user_id").where(games: {status: 0..2})
end
# 通关的关卡数
def pass_games_count
@user_extensions.joins("join games on games.user_id = user_extensions.user_id").where(games: {status: 2})
end
# 评测总数
def evalute_count
@user_extensions.joins("join games on games.user_id = user_extensions.user_id").sum(:evalute_count)
end
end

@ -17,7 +17,7 @@
<li> <li>
<%= sidebar_item_group('#school-submenu', '学校统计', icon: 'area-chart') do %> <%= sidebar_item_group('#school-submenu', '学校统计', icon: 'area-chart') do %>
<li><%= sidebar_item(admins_daily_school_statistics_path, '统计总表', icon: 'bar-chart', controller: 'admins-daily_school_statistics') %></li> <li><%= sidebar_item(admins_daily_school_statistics_path, '统计总表', icon: 'bar-chart', controller: 'admins-daily_school_statistics') %></li>
<li><%= sidebar_item(admins_school_statistics_path, '数据变化报表', icon: 'line-chart', controller: 'admins-school_statistics') %></li> <li><%= sidebar_item(admins_school_statistics_path, '数据变化报表', icon: 'line-chart', controller: 'admins-schools') %></li>
<% end %> <% end %>
</li> </li>

@ -0,0 +1,8 @@
#coding=utf-8
desc "同步高校数据"
namespace :school_statistic do
task sync_records: :environment do
end
end

@ -26248,23 +26248,23 @@ input.form-control {
color: #6c757d; color: #6c757d;
} }
/* line 3, app/assets/stylesheets/admins/school_statistics.scss */ /* line 3, app/assets/stylesheets/admins/schools.scss */
.admins-school-statistics-index-page .school-statistic-list-form .time-select { .admins-school-statistics-index-page .school-statistic-list-form .time-select {
-webkit-box-flex: 1; -webkit-box-flex: 1;
flex: 1; flex: 1;
} }
/* line 8, app/assets/stylesheets/admins/school_statistics.scss */ /* line 8, app/assets/stylesheets/admins/schools.scss */
.admins-school-statistics-index-page .school-statistic-list-form .type-box .btn { .admins-school-statistics-index-page .school-statistic-list-form .type-box .btn {
margin: 0 5px; margin: 0 5px;
} }
/* line 11, app/assets/stylesheets/admins/school_statistics.scss */ /* line 11, app/assets/stylesheets/admins/schools.scss */
.admins-school-statistics-index-page .school-statistic-list-form .search-input { .admins-school-statistics-index-page .school-statistic-list-form .search-input {
width: 220px; width: 220px;
} }
/* line 15, app/assets/stylesheets/admins/school_statistics.scss */ /* line 15, app/assets/stylesheets/admins/schools.scss */
.admins-school-statistics-index-page .school-statistic-list-form .contrast-date-container { .admins-school-statistics-index-page .school-statistic-list-form .contrast-date-container {
display: -webkit-box; display: -webkit-box;
display: flex; display: flex;
@ -26272,7 +26272,7 @@ input.form-control {
align-items: center; align-items: center;
} }
/* line 22, app/assets/stylesheets/admins/school_statistics.scss */ /* line 22, app/assets/stylesheets/admins/schools.scss */
.admins-school-statistics-index-page .school-statistic-list-container .contrast-column-select { .admins-school-statistics-index-page .school-statistic-list-container .contrast-column-select {
position: absolute; position: absolute;
right: 30px; right: 30px;
@ -26280,12 +26280,12 @@ input.form-control {
width: 130px; width: 130px;
} }
/* line 29, app/assets/stylesheets/admins/school_statistics.scss */ /* line 29, app/assets/stylesheets/admins/schools.scss */
.admins-school-statistics-index-page .school-statistic-list-container .relative { .admins-school-statistics-index-page .school-statistic-list-container .relative {
position: relative; position: relative;
} }
/* line 33, app/assets/stylesheets/admins/school_statistics.scss */ /* line 33, app/assets/stylesheets/admins/schools.scss */
.admins-school-statistics-index-page .school-statistic-list-container .right-border::after { .admins-school-statistics-index-page .school-statistic-list-container .right-border::after {
position: absolute; position: absolute;
top: 10px; top: 10px;

Loading…
Cancel
Save