Fix bookmarks admin dashboard counts to include bookmarks that were deleted

This commit is contained in:
Neil Lalonde 2013-04-30 12:52:12 -04:00
parent 6f0d68fe5f
commit 20d73a4151
2 changed files with 4 additions and 4 deletions

View File

@ -51,7 +51,7 @@ class PostAction < ActiveRecord::Base
end
def self.count_per_day_for_type(sinceDaysAgo = 30, post_action_type)
where(post_action_type_id: post_action_type).where('created_at > ?', sinceDaysAgo.days.ago).group('date(created_at)').order('date(created_at)').count
unscoped.where(post_action_type_id: post_action_type).where('created_at > ?', sinceDaysAgo.days.ago).group('date(created_at)').order('date(created_at)').count
end
def self.clear_flags!(post, moderator_id, action_type_id = nil)
@ -62,7 +62,7 @@ class PostAction < ActiveRecord::Base
moderator_id == -1 ? PostActionType.auto_action_flag_types.values : PostActionType.flag_types.values
end
PostAction.update_all({ deleted_at: Time.now, deleted_by: moderator_id }, { post_id: post.id, post_action_type_id: actions })
PostAction.update_all({ deleted_at: Time.zone.now, deleted_by: moderator_id }, { post_id: post.id, post_action_type_id: actions })
f = actions.map{|t| ["#{PostActionType.types[t]}_count", 0]}
@ -114,7 +114,7 @@ class PostAction < ActiveRecord::Base
def self.remove_act(user, post, post_action_type_id)
if action = where(post_id: post.id, user_id: user.id, post_action_type_id: post_action_type_id).first
action.destroy
action.deleted_at = Time.now
action.deleted_at = Time.zone.now
action.run_callbacks(:save)
end
end

View File

@ -118,7 +118,7 @@ class Report
PostAction.count_per_day_for_type(30, post_action_type).each do |date, count|
report.data << {x: date, y: count}
end
query = PostAction.where(post_action_type_id: post_action_type)
query = PostAction.unscoped.where(post_action_type_id: post_action_type)
report.total = query.count
report.prev30Days = query.where('created_at > ? and created_at < ?', 60.days.ago, 30.days.ago).count
end