修改poll_publish_rake

dev_auth
SylorHuang 5 years ago
parent b4418242c3
commit 5a67649521

@ -83,7 +83,7 @@ namespace :poll_publish do
end end
task :end => :environment do task :end => :environment do
puts "--------------------------------poll_publish end start"
#1.统一设置的截止 #1.统一设置的截止
polls = Poll.includes(:poll_users).where("polls_status = 2 AND unified_setting = true AND end_time <=?",Time.now + 900) polls = Poll.includes(:poll_users).where("polls_status = 2 AND unified_setting = true AND end_time <=?",Time.now + 900)
polls.each do |poll| polls.each do |poll|
@ -98,7 +98,9 @@ namespace :poll_publish do
polls_group_settings.each do |poll_setting| polls_group_settings.each do |poll_setting|
poll = poll_setting.poll poll = poll_setting.poll
if poll&.end_time <= Time.now if poll&.end_time <= Time.now
poll.update_column('polls_status', 3) poll.update_column('polls_status', 3)
puts "########__________________############{poll.polls_status}"
end end
users = poll.course.course_members.where(course_group_id: poll_setting.course_group_id) users = poll.course.course_members.where(course_group_id: poll_setting.course_group_id)
poll.poll_users.where(user_id: users.pluck(:user_id)).where("commit_status = 0 and start_at is not null").update_all(commit_status: 1, end_at: Time.now) poll.poll_users.where(user_id: users.pluck(:user_id)).where("commit_status = 0 and start_at is not null").update_all(commit_status: 1, end_at: Time.now)
@ -107,7 +109,10 @@ namespace :poll_publish do
# poll_user.update_attributes(:commit_status => 1, :end_at => Time.now) # poll_user.update_attributes(:commit_status => 1, :end_at => Time.now)
# end # end
# end # end
end end
puts "--------------------------------poll_publish end end"
# PollGroupSetting.where("end_time < ? and end_time > ?", Time.now + 1800, Time.now - 1800).each do |poll_setting| # PollGroupSetting.where("end_time < ? and end_time > ?", Time.now + 1800, Time.now - 1800).each do |poll_setting|
# poll = poll_setting.poll # poll = poll_setting.poll

Loading…
Cancel
Save