|
|
|
@ -2,9 +2,10 @@
|
|
|
|
|
namespace :sync do
|
|
|
|
|
task :public_message => :environment do
|
|
|
|
|
subject_id = ENV['args'].split(",")[0] # 对应课程的id
|
|
|
|
|
board_id = ENV['args'].split(",")[1]
|
|
|
|
|
message_id = ENV['args'].split(",")[2]
|
|
|
|
|
status = ENV['args'].split(",")[3] # 表示相应的期数
|
|
|
|
|
shixun_id = ENV['args'].split(",")[1] # 对应课程的id
|
|
|
|
|
board_id = ENV['args'].split(",")[2]
|
|
|
|
|
message_id = ENV['args'].split(",")[3]
|
|
|
|
|
status = ENV['args'].split(",")[4] # 表示相应的期数
|
|
|
|
|
|
|
|
|
|
if status.to_i == 1
|
|
|
|
|
start_time = '2018-12-16'
|
|
|
|
@ -21,7 +22,6 @@ namespace :sync do
|
|
|
|
|
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)
|
|
|
|
|
if discusses.present?
|
|
|
|
|
discusses.find_each do |discuss|
|
|
|
|
@ -52,7 +52,14 @@ namespace :sync do
|
|
|
|
|
end_time = '2022-07-28'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
discusses = Discuss.where(dis_id: shixun_id).where("parent_id is null and created_at >? and created_at <?", start_time, end_time)
|
|
|
|
|
if subject_id.to_i == -1
|
|
|
|
|
discusses = Shixun.where(dis_id: shixun_id).where("parent_id is nul")
|
|
|
|
|
else
|
|
|
|
|
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("parent_id is null")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
discusses.each do |discuss|
|
|
|
|
|
rand_created_on = random_time start_time, end_time
|
|
|
|
|
puts discuss.id
|
|
|
|
|