mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 18:24:52 -06: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 ||= [
|
||||
'visits',
|
||||
'signups',
|
||||
'profile_views',
|
||||
'topics',
|
||||
'posts',
|
||||
'time_to_first_response',
|
||||
|
@ -98,6 +98,14 @@ class Report
|
||||
report_about report, User.real, :count_by_signup_date
|
||||
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)
|
||||
basic_report_about report, Topic, :listable_count_per_day, report.start_date, report.end_date, report.category_id
|
||||
countable = Topic.listable_topics
|
||||
|
@ -39,4 +39,9 @@ class UserProfileView < ActiveRecord::Base
|
||||
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
|
||||
|
@ -575,6 +575,10 @@ en:
|
||||
title: "New Users"
|
||||
xaxis: "Day"
|
||||
yaxis: "Number of new users"
|
||||
profile_views:
|
||||
title: "User Profile Views"
|
||||
xaxis: "Day"
|
||||
yaxis: "Number of user profiles viewed"
|
||||
topics:
|
||||
title: "Topics"
|
||||
xaxis: "Day"
|
||||
|
Loading…
Reference in New Issue
Block a user