|
|
|
@ -2,9 +2,8 @@
|
|
|
|
|
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] # 表示相应的期数
|
|
|
|
|
message_id = ENV['args'].split(",")[1]
|
|
|
|
|
status = ENV['args'].split(",")[2] # 表示相应的期数
|
|
|
|
|
|
|
|
|
|
if status.to_i == 1
|
|
|
|
|
start_time = '2018-12-16'
|
|
|
|
@ -23,17 +22,11 @@ namespace :sync do
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
discusses = Discuss.where(dis_id: shixun_ids).where("created_at >? and created_at <?", start_time, end_time)
|
|
|
|
|
board = Board.find(board_id)
|
|
|
|
|
message = Message.find(message_id)
|
|
|
|
|
if discusses.present?
|
|
|
|
|
discusses.find_each do |discuss|
|
|
|
|
|
puts discuss.user_id
|
|
|
|
|
puts discuss.content
|
|
|
|
|
Message.create!(board: board, root_id: message.root_id || message.id,
|
|
|
|
|
author: discuss.user_id, parent: message,
|
|
|
|
|
message_detail_attributes: {
|
|
|
|
|
content: discuss.try(:content)
|
|
|
|
|
})
|
|
|
|
|
MessageDetail.create!(message_id: message_id, content: discuss.try(:content))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|