@ -1,5 +1,5 @@
#coding=utf-8
#coding=utf-8
# 执行示例 bundle exec rake public_course:student args=149,2903
# 执行示例 RAILS_ENV=production bundle exec rake public_classes:student args=3,3056,'2019-03-01','2019-03-31',10,1
# args 第一个参数是subject_id, 第二个参数是课程course_id
# args 第一个参数是subject_id, 第二个参数是课程course_id
# 第一期时间: 2018-12-16 至2019-03-31
# 第一期时间: 2018-12-16 至2019-03-31
# 第二期时间: 2019-04-07 至2019-07-28
# 第二期时间: 2019-04-07 至2019-07-28
@ -22,10 +22,13 @@ namespace :public_classes do
task :student = > :environment do
task :student = > :environment do
puts " subject_id is #{ subject_id } "
puts " subject_id is #{ subject_id } "
puts " course_id is #{ course_id } "
puts " course_id is #{ course_id } "
puts " start time is #{ start_time } "
puts " end time is #{ end_time } "
puts " limt is #{ limit } "
user_ids = Myshixun . find_by_sql ( " select distinct(user_id) from myshixuns where created_at between #{ start_time } and #{ end_time } and shixun_id in (select shixun_id from stage_shixuns
user_ids = Myshixun . find_by_sql ( " select distinct(user_id) from myshixuns where created_at between ' #{ start_time } ' and ' #{ end_time } ' and shixun_id in (select shixun_id from stage_shixuns
where stage_id in ( select id from stages where subject_id = #{subject_id})) limit #{limit}").map(&:user_id)
where stage_id in ( select id from stages where subject_id = #{subject_id})) limit #{limit}").map(&:user_id)
puts user_ids
puts " user_ids count is #{ user_ids . count } "
if user_ids . present?
if user_ids . present?
user_ids . each do | user_id |
user_ids . each do | user_id |
puts user_id
puts user_id