From 20d73a41515e649214fade96a9bfc44df23f36a8 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Tue, 30 Apr 2013 12:52:12 -0400 Subject: [PATCH] Fix bookmarks admin dashboard counts to include bookmarks that were deleted --- app/models/post_action.rb | 6 +++--- app/models/report.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/post_action.rb b/app/models/post_action.rb index 6793ff97c6d..9ef15291259 100644 --- a/app/models/post_action.rb +++ b/app/models/post_action.rb @@ -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 diff --git a/app/models/report.rb b/app/models/report.rb index 9052357a81e..bfd8dd39719 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -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