From 640adcedef3cbda9329454c415ca4ad98bd0a9ee Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 29 Jul 2019 20:26:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20190729122213_delete_myshixun_games_for_users.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 db/migrate/20190729122213_delete_myshixun_games_for_users.rb diff --git a/db/migrate/20190729122213_delete_myshixun_games_for_users.rb b/db/migrate/20190729122213_delete_myshixun_games_for_users.rb new file mode 100644 index 000000000..9c93372e9 --- /dev/null +++ b/db/migrate/20190729122213_delete_myshixun_games_for_users.rb @@ -0,0 +1,11 @@ +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}") + myshixuns.destroy! + end + end + end +end From a38b598fa3c556641263c8ed52e92295bbc578da Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 29 Jul 2019 20:27:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20190729122213_delete_myshixun_games_for_users.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20190729122213_delete_myshixun_games_for_users.rb b/db/migrate/20190729122213_delete_myshixun_games_for_users.rb index 9c93372e9..d52369828 100644 --- a/db/migrate/20190729122213_delete_myshixun_games_for_users.rb +++ b/db/migrate/20190729122213_delete_myshixun_games_for_users.rb @@ -4,7 +4,7 @@ class DeleteMyshixunGamesForUsers < ActiveRecord::Migration[5.2] 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}") - myshixuns.destroy! + m.destroy! end end end