From f5feab59e024eaa5d959b08af9d0a170861c4818 Mon Sep 17 00:00:00 2001 From: nilsding Date: Sun, 28 Dec 2014 00:02:01 +0100 Subject: [PATCH] as --- Rakefile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Rakefile b/Rakefile index 02a1599a..df57da0c 100644 --- a/Rakefile +++ b/Rakefile @@ -98,6 +98,26 @@ namespace :justask do puts "Purged #{destroyed_count} dead notifications." end + desc "Fixes everything else" + task fix_db: :environment do + format = '%t (%c/%C) [%b>%i] %e' + total = Inbox.count + progress = ProgressBar.create title: 'Processing inboxes', format: format, starting_at: 0, total: total + destroyed_count = { + inbox: 0 + } + + Inbox.all.each do |n| + if n.question.nil? + n.destroy + destroyed_count[:inbox] += 1 + end + progress.increment + end + + puts "Purged #{destroyed_count[:inbox]} dead inbox entries." + end + desc "Prints lonely people." task loners: :environment do people = {}