From e38eabc26944fcfd85272759c1fb1e54b86aa5ed Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 5 Mar 2020 00:03:23 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/sync_evaluate.rake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/tasks/sync_evaluate.rake diff --git a/lib/tasks/sync_evaluate.rake b/lib/tasks/sync_evaluate.rake new file mode 100644 index 000000000..7ceccdb48 --- /dev/null +++ b/lib/tasks/sync_evaluate.rake @@ -0,0 +1,16 @@ +desc "同步天府学院数据, 执行顺序依次 import_teaches、 import_courses、 import_students、import_course_members" + +namespace :sync_evaluate do + task outpus_count: :environment do + School.find_each do |school| + evaluate_count = Game.find_by_sql("select sum(g.evaluate_count) as e_count from games g, user_extensions ue where + g.user_id = ue.user_id and ue.school_id = #{school}.id").firt.try(:e_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 \ No newline at end of file From d56508d264d5853dd0abf7c1975603837bafb796 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 5 Mar 2020 00:04:31 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9rake=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/sync_evaluate.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/sync_evaluate.rake b/lib/tasks/sync_evaluate.rake index 7ceccdb48..c0f43c66b 100644 --- a/lib/tasks/sync_evaluate.rake +++ b/lib/tasks/sync_evaluate.rake @@ -1,4 +1,4 @@ -desc "同步天府学院数据, 执行顺序依次 import_teaches、 import_courses、 import_students、import_course_members" +desc "同步学院或者单位评测数" namespace :sync_evaluate do task outpus_count: :environment do From 73184b65b234bda7a9a6e67451fbc2892ac88eab Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 5 Mar 2020 00:07:28 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=8F=AA=E8=83=BD=E5=AF=BC=E5=87=BA50?= =?UTF-8?q?=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/user_schools_statistics_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admins/user_schools_statistics_controller.rb b/app/controllers/admins/user_schools_statistics_controller.rb index 2290761da..38e966880 100644 --- a/app/controllers/admins/user_schools_statistics_controller.rb +++ b/app/controllers/admins/user_schools_statistics_controller.rb @@ -1,7 +1,7 @@ class Admins::UserSchoolsStatisticsController < Admins::BaseController def export - params[:per_page] = 10000 + params[:per_page] = 50 _count, @schools = Admins::UserSchoolsStatisticQuery.call(params) filename = ['用户运营统计', Time.zone.now.strftime('%Y%m%d%H%M%S')].join('-') << '.xlsx' From 78ed9a04e5ceb886feaefdc1f67f3e0928fd599c Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 5 Mar 2020 00:07:30 +0800 Subject: [PATCH 4/4] =?UTF-8?q?rake=E6=89=93=E5=8D=B0=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/sync_evaluate.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tasks/sync_evaluate.rake b/lib/tasks/sync_evaluate.rake index c0f43c66b..f6f6e9482 100644 --- a/lib/tasks/sync_evaluate.rake +++ b/lib/tasks/sync_evaluate.rake @@ -3,6 +3,7 @@ desc "同步学院或者单位评测数" namespace :sync_evaluate do task outpus_count: :environment do School.find_each do |school| + puts school.id evaluate_count = Game.find_by_sql("select sum(g.evaluate_count) as e_count from games g, user_extensions ue where g.user_id = ue.user_id and ue.school_id = #{school}.id").firt.try(:e_count)