Created
October 28, 2009 19:31
-
-
Save clarabstract/220746 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 54368c5fc6f4bdecc7018462e03d1730fdf2507c Mon Sep 17 00:00:00 2001 | |
| From: Patrick Aljord <patcito@zeta.cc> | |
| Date: Wed, 28 Oct 2009 13:28:18 -0500 | |
| Subject: [PATCH] added task to update comments counts in entries | |
| --- | |
| lib/tasks/integrity.rake | 19 +++++++++++++++++-- | |
| 1 files changed, 17 insertions(+), 2 deletions(-) | |
| diff --git a/lib/tasks/integrity.rake b/lib/tasks/integrity.rake | |
| index 7d9c4f6..61f9c04 100644 | |
| --- a/lib/tasks/integrity.rake | |
| +++ b/lib/tasks/integrity.rake | |
| @@ -59,9 +59,10 @@ namespace :db do | |
| "torrents:kill_dtfsless_dtfms", # ran in dev, prod | |
| "resources:remove_dupes", # ran in dev, prod | |
| "features:update_features_weight", # ran in dev, prod | |
| - "videos:resources:populate", | |
| + "videos:resources:populate", # ran in dev | |
| "torrents:downloads_count_to_zero", # ran in dev | |
| "torrents:new_downloads_count", # ran in dev | |
| + "entries:update_comments_count", | |
| ] | |
| desc "Fix timestamps that were broken before without_timestamps{...}" | |
| task :fix_timestamps => :environment do | |
| @@ -760,7 +761,21 @@ namespace :db do | |
| end | |
| namespace :entries do | |
| - desc "Set stickies to false" | |
| + desc "Update comments count" | |
| + task :update_comments_count => :environment do | |
| + Entry.reset_column_information | |
| + entries = Entry.find(:all) | |
| + Entry.transaction do | |
| + entries.each_with_index do |e,i| | |
| + puts "updating entry #{i}/#{entries.size-1}" | |
| + e.comments_count = e.comments.length | |
| + e.save | |
| + end | |
| + end | |
| + puts "done." | |
| + end | |
| + | |
| + desc "Set stickies to false" | |
| task :set_sticky_to_false => :environment do | |
| sql = "UPDATE entries SET sticky='f'" | |
| puts "updating all entries: #{sql}" | |
| -- | |
| 1.6.4.4+GitX |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment