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/db/migrate/20190729122213_delete_myshi...

12 lines
373 B

class DeleteMyshixunGamesForUsers < ActiveRecord::Migration[5.2]
def change
myshixuns = Myshixun.where("created_at > '2019-07-26 19:00:00' and repo_name is null")
myshixuns.find_each do |m|
if m.games.count == m.games.select{|g| g.status == 3}.count
puts("#######login: #{User.find(m.user_id).login}")
m.destroy!
end
end
end
end