You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/lib/tasks/shixuns.rake

22 lines
637 B

#coding=utf-8
desc "纠正学生实训耗时不准的问题"
namespace :shixuns do
task correct_the_shixun_cost_time: :environment do
puts "myshixun_id: #{ENV['myshixun_id']}"
if ENV['myshixun_id'].present?
myshixun = Myshixun.find(ENV['myshixun_id'])
myshixun.games.where(status: 2).each do |game|
puts "open_time: #{game.open_time.to_i}"
puts "end_time: #{game.end_time.to_i}"
puts "game_id: #{game.id}"
cost_time = game.end_time.to_i - game.open_time.to_i
puts "cost_time: #{cost_time}"
game.update_attributes!(cost_time: cost_time)
end
end
end
end