Merge branch 'master' of git.rrerr.net:justask/justask

This commit is contained in:
Andreas N 2014-12-19 23:33:50 +01:00
commit b9e1432889
2 changed files with 19 additions and 1 deletions

View File

@ -79,4 +79,22 @@ namespace :justask do
puts "#{sprintf "%3d", u.id}. #{u.screen_name}"
end
end
desc "Fixes the notifications"
task fix_notifications: :environment do
format = '%t (%c/%C) [%b>%i] %e'
total = Notification.count
progress = ProgressBar.create title: 'Processing notifications', format: format, starting_at: 0, total: total
destroyed_count = 0
Notification.all.each do |n|
if n.target.nil?
n.destroy
destroyed_count += 1
end
progress.increment
end
puts "Purged #{destroyed_count} dead notifications."
end
end

View File

@ -40,6 +40,6 @@ class UserController < ApplicationController
def questions
@title = 'Questions'
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first
@questions = @user.questions.reverse_order.paginate(page: params[:page])
@questions = @user.questions.where(author_is_anonymous: false).reverse_order.paginate(page: params[:page])
end
end