mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 10:24:39 +08:00
FIX: show private message topic count on admin dashboard reports
This commit is contained in:
@ -21,6 +21,7 @@ class AdminDashboardData
|
||||
|
||||
PRIVATE_MESSAGE_REPORTS ||= [
|
||||
'user_to_user_private_messages',
|
||||
'user_to_user_private_messages_with_replies',
|
||||
'system_private_messages',
|
||||
'notify_moderators_private_messages',
|
||||
'notify_user_private_messages',
|
||||
|
@ -202,14 +202,20 @@ class Report
|
||||
# Private messages counts:
|
||||
|
||||
def self.private_messages_report(report, topic_subtype)
|
||||
basic_report_about report, Post, :private_messages_count_per_day, report.start_date, report.end_date, topic_subtype
|
||||
add_counts report, Post.private_posts.with_topic_subtype(topic_subtype), 'posts.created_at'
|
||||
basic_report_about report, Topic, :private_message_topics_count_per_day, report.start_date, report.end_date, topic_subtype
|
||||
add_counts report, Topic.private_messages.with_subtype(topic_subtype), 'topics.created_at'
|
||||
end
|
||||
|
||||
def self.report_user_to_user_private_messages(report)
|
||||
private_messages_report report, TopicSubtype.user_to_user
|
||||
end
|
||||
|
||||
def self.report_user_to_user_private_messages_with_replies(report)
|
||||
topic_subtype = TopicSubtype.user_to_user
|
||||
basic_report_about report, Post, :private_messages_count_per_day, report.start_date, report.end_date, topic_subtype
|
||||
add_counts report, Post.private_posts.with_topic_subtype(topic_subtype), 'posts.created_at'
|
||||
end
|
||||
|
||||
def self.report_system_private_messages(report)
|
||||
private_messages_report report, TopicSubtype.system_message
|
||||
end
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user