mirror of
https://github.com/discourse/discourse.git
synced 2025-03-25 02:45:36 +08:00
FEATURE: Admin dashboard data for user profile views.
This commit is contained in:
parent
7acc93b2a0
commit
21725cc907
@ -6,6 +6,7 @@ class AdminDashboardData
|
|||||||
GLOBAL_REPORTS ||= [
|
GLOBAL_REPORTS ||= [
|
||||||
'visits',
|
'visits',
|
||||||
'signups',
|
'signups',
|
||||||
|
'profile_views',
|
||||||
'topics',
|
'topics',
|
||||||
'posts',
|
'posts',
|
||||||
'time_to_first_response',
|
'time_to_first_response',
|
||||||
|
@ -98,6 +98,14 @@ class Report
|
|||||||
report_about report, User.real, :count_by_signup_date
|
report_about report, User.real, :count_by_signup_date
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.report_profile_views(report)
|
||||||
|
start_date = report.start_date.to_date
|
||||||
|
end_date = report.end_date.to_date
|
||||||
|
basic_report_about report, UserProfileView, :profile_views_by_day, start_date, end_date
|
||||||
|
report.total = UserProfile.sum(:views)
|
||||||
|
report.prev30Days = UserProfileView.where("viewed_at >= ? AND viewed_at < ?", start_date - 30.days, start_date + 1).count
|
||||||
|
end
|
||||||
|
|
||||||
def self.report_topics(report)
|
def self.report_topics(report)
|
||||||
basic_report_about report, Topic, :listable_count_per_day, report.start_date, report.end_date, report.category_id
|
basic_report_about report, Topic, :listable_count_per_day, report.start_date, report.end_date, report.category_id
|
||||||
countable = Topic.listable_topics
|
countable = Topic.listable_topics
|
||||||
|
@ -39,4 +39,9 @@ class UserProfileView < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.profile_views_by_day(start_date, end_date)
|
||||||
|
profile_views = self.where("viewed_at >= ? AND viewed_at < ?", start_date, end_date + 1.day)
|
||||||
|
profile_views.group("date(viewed_at)").order("date(viewed_at)").count
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -575,6 +575,10 @@ en:
|
|||||||
title: "New Users"
|
title: "New Users"
|
||||||
xaxis: "Day"
|
xaxis: "Day"
|
||||||
yaxis: "Number of new users"
|
yaxis: "Number of new users"
|
||||||
|
profile_views:
|
||||||
|
title: "User Profile Views"
|
||||||
|
xaxis: "Day"
|
||||||
|
yaxis: "Number of user profiles viewed"
|
||||||
topics:
|
topics:
|
||||||
title: "Topics"
|
title: "Topics"
|
||||||
xaxis: "Day"
|
xaxis: "Day"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user