FIX: show private message topic count on admin dashboard reports

This commit is contained in:
Arpit Jalan
2018-03-27 14:00:08 +05:30
parent 94deb482ae
commit 518f7ba91b
5 changed files with 20 additions and 3 deletions

View File

@ -191,6 +191,8 @@ class Topic < ActiveRecord::Base
where("topics.category_id IS NULL OR topics.category_id IN (SELECT id FROM categories WHERE #{condition[0]})", condition[1])
}
scope :with_subtype, ->(subtype) { where('topics.subtype = ?', subtype) }
attr_accessor :ignore_category_auto_close
attr_accessor :skip_callbacks
@ -1307,6 +1309,10 @@ SQL
MiniSuffix.domain(URI.parse(URI.encode(self.featured_link)).hostname)
end
def self.private_message_topics_count_per_day(start_date, end_date, topic_subtype)
private_messages.with_subtype(topic_subtype).where('topics.created_at >= ? AND topics.created_at <= ?', start_date, end_date).group('date(topics.created_at)').order('date(topics.created_at)').count
end
private
def update_category_topic_count_by(num)