shixun_ids=Shixun.find_by_sql("select shixun_id from stage_shixuns where stage_id in (select id from stages where
subject_id=#{subject_id}) ").map(&:shixun_id)
discusses=Discuss.where(dis_id:shixun_ids).where("created_at >? and created_at <?",start_time,end_time)
ifdiscusses.present?
discusses.find_each do|discuss|
discusses.limit(limit).find_eachdo|discuss|
putsdiscuss.user_id
putsboard_id
putsmessage_id
@ -35,23 +27,6 @@ namespace :sync do
end
task:sigle_message=>:environmentdo
subject_id=ENV['args'].split(",")[0]# 对应课程的id
shixun_id=ENV['args'].split(",")[1]# 对应课程的id
board_id=ENV['args'].split(",")[2]
message_id=ENV['args'].split(",")[3]
status=ENV['args'].split(",")[4]# 表示相应的期数
ifstatus.to_i==1
start_time='2018-12-16'
end_time='2019-04-01'
elsifstatus.to_i==2
start_time='2019-04-07'
end_time='2019-07-28'
else
# 这种情况是取所有的
start_time='2015-01-01'
end_time='2022-07-28'
end
ifsubject_id.to_i==-1
discusses=Discuss.where("parent_id is null and dis_id=?",shixun_id)
@ -119,18 +94,8 @@ namespace :sync do
end
end
task:board_count=>:environmentdo
Course.find_eachdo|course|
putscourse.id
begin
messages_count=Message.find_by_sql("select count(*) as count from messages where board_id in (select id from boards where course_id=#{course.id})").first.try(:count)