Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

video_transcode
杨树明 5 years ago
commit 523dd2327b

@ -0,0 +1,2 @@
web: cd client && npm start
api: bundle exec rails s -p 3001

@ -104,7 +104,7 @@ class HomeworkCommon < ApplicationRecord
end
def user_work user_id
work = self.student_works.find_by_user_id(user_id) || StudentWork.create!(homework_common_id: id, user_id: user_id)
work = StudentWork.find_by(homework_common_id: id, user_id: user_id) || StudentWork.create!(homework_common_id: id, user_id: user_id)
end
# 是否在补交阶段内

@ -0,0 +1,20 @@
class StaAll < ApplicationRecord
# t.integer :school_id 学校ID
# t.integer :tea_count 老师数
# t.integer :stu_count 学生数
# t.integer :active_users_count 活跃用户数3个月内有登录
# t.integer :courses_count 总课堂数
# t.integer :curr_courses_count 正在进行的课堂数
# t.integer :homw_shixuns_count 实训作业数
# t.integer :homw_other_count 其它类型作业数
# t.integer :sources_count 资源数
# t.integer :videos_count 视频总个数
# t.integer :shixuns_count 制作实训总数
# t.integer :myshixuns_count 挑战实训总数
# t.integer :mys_passed_count 通关的实训总数
# t.integer :games_count 挑战的总关卡数
# t.integer :games_passed_count 通关的总关卡数
# t.integer :build_count 评测总数
belongs_to :school
end

@ -19,6 +19,11 @@ class Weapps::SubjectQuery < ApplicationQuery
subjects = subjects.joins(:sub_discipline_containers).where(sub_discipline_containers: {container_type: "Subject"})
end
# 搜索
if params[:keyword].present?
subjects = subjects.where("subjects.name like '%#{params[:keyword]}%'")
end
subjects = subjects.left_joins(:shixuns, :repertoire).select('subjects.id, subjects.name, subjects.excellent, subjects.stages_count, subjects.status, subjects.homepage_show,
subjects.shixuns_count, subjects.repertoire_id, subjects.updated_at, IFNULL(sum(shixuns.myshixuns_count), 0) myshixuns_count')
.group('subjects.id').order("subjects.homepage_show #{sort_type}, #{order_type} #{sort_type}")

@ -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

@ -1,20 +1,20 @@
class StatisticSchoolReportTask
def call
School.find_each do |school|
evaluate_count = Game.joins(:challenge)
.joins('LEFT JOIN course_members ON course_members.user_id = games.user_id')
.joins('LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = challenges.shixun_id')
.joins('LEFT JOIN homework_commons hc ON hcs.homework_common_id = hc.id AND hc.homework_type = 4')
.joins('LEFT JOIN courses ON hc.course_id = courses.id AND course_members.course_id = courses.id')
.where(courses: { school_id: school.id })
.sum(:evaluate_count)
report = SchoolReport.find_or_initialize_by(school_id: school.id)
report.school_name = school.name
report.shixun_evaluate_count = evaluate_count
report.save
end
# School.find_each do |school|
# evaluate_count = Game.joins(:challenge)
# .joins('LEFT JOIN course_members ON course_members.user_id = games.user_id')
# .joins('LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = challenges.shixun_id')
# .joins('LEFT JOIN homework_commons hc ON hcs.homework_common_id = hc.id AND hc.homework_type = 4')
# .joins('LEFT JOIN courses ON hc.course_id = courses.id AND course_members.course_id = courses.id')
# .where(courses: { school_id: school.id })
# .sum(:evaluate_count)
#
# report = SchoolReport.find_or_initialize_by(school_id: school.id)
#
# report.school_name = school.name
# report.shixun_evaluate_count = evaluate_count
#
# report.save
# end
end
end

@ -11,7 +11,7 @@
<th width="13%">
<%= sort_tag(name: 'shixun_evaluate_count', path: admins_daily_school_statistics_path) do %>
实训评测总数
<i class="fa fa-question-circle" data-toggle="tooltip" data-html="true" data-placement="top" title="数据更新时间为<br/>当日6点、12点、18点、24点"></i>
<i class="fa fa-question-circle" data-toggle="tooltip" data-html="true" data-placement="top" title="数据每晚4点更新"></i>
<% end %>
</th>
<th width="11%"><%= sort_tag('实训作业总数', name: 'homework_count', path: admins_daily_school_statistics_path) %></th>

@ -17,7 +17,7 @@
<li>
<%= 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_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 %>
</li>

@ -0,0 +1,25 @@
class CreateStaAlls < ActiveRecord::Migration[5.2]
def change
create_table :sta_alls do |t|
t.integer :school_id, default: 0
t.integer :tea_count, default: 0
t.integer :stu_count, default: 0
t.integer :active_users_count, default: 0
t.integer :courses_count, default: 0
t.integer :curr_courses_count, default: 0
t.integer :homw_shixuns_count, default: 0
t.integer :homw_other_count, default: 0
t.integer :sources_count, default: 0
t.integer :videos_count, default: 0
t.integer :shixuns_count, default: 0
t.integer :myshixuns_count, default: 0
t.integer :mys_passed_count, default: 0
t.integer :games_count, default: 0
t.integer :games_passed_count, default: 0
t.integer :build_count, default: 0
t.timestamps
end
end
end

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

@ -0,0 +1,16 @@
desc "统计每个学校使用数据"
namespace :static_all do
task :repo => :environment do
School.find_each(batch_size: 100) do |school|
User.joins(:user_extension).where(school_id: school.id)
report = StaAll.find_or_initialize_by(school_id: school.id)
report.shixun_evaluate_count = evaluate_count
report.save
end
end
end

@ -26248,23 +26248,23 @@ input.form-control {
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 {
-webkit-box-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 {
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 {
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 {
display: -webkit-box;
display: flex;
@ -26272,7 +26272,7 @@ input.form-control {
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 {
position: absolute;
right: 30px;
@ -26280,12 +26280,12 @@ input.form-control {
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 {
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 {
position: absolute;
top: 10px;

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe StaAll, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save