From f7a88a63e0d737ec21773373ddcdd7516a510ae8 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 13 Jan 2016 18:46:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A1=B9=E7=9B=AE=E7=BC=BA?= =?UTF-8?q?=E9=99=B7=E5=8A=A8=E6=80=81=E7=9A=84=E6=9B=B4=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...13090435_update_forge_and_user_activity.rb | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 db/migrate/20160113090435_update_forge_and_user_activity.rb diff --git a/db/migrate/20160113090435_update_forge_and_user_activity.rb b/db/migrate/20160113090435_update_forge_and_user_activity.rb new file mode 100644 index 000000000..d8fbbbfb6 --- /dev/null +++ b/db/migrate/20160113090435_update_forge_and_user_activity.rb @@ -0,0 +1,42 @@ +class UpdateForgeAndUserActivity < ActiveRecord::Migration + def up + user_count = UserActivity.all.count / 30 + 2 + transaction do + for i in 1 ... user_count do i + UserActivity.page(i).per(30).each do |user_act| + if user_act.act_type = 'Issue' + if user_act.act + if user_act.act.journals.count > 0 + user_act.updated_at = user_act.act.journals.maximum("created_on") + user_act.save + end + else + user_act.destroy + end + end + end + end + end + + for_count = ForgeActivity.all.count / 30 + 2 + transaction do + for i in 1 ... for_count do i + ForgeActivity.page(i).per(30).each do |for_act| + if for_act.forge_act_type = 'Issue' + if for_act.forge_act + if for_act.forge_act.journals.count > 0 + for_act.updated_at = for_act.forge_act.journals.maximum("created_on") + for_act.save + end + else + for_act.destroy + end + end + end + end + end + end + + def down + end +end