FEATURE: Admin dashboard data for user profile views.

This commit is contained in:
Guo Xiang Tan 2015-09-15 01:30:06 +08:00
parent 7acc93b2a0
commit 21725cc907
4 changed files with 18 additions and 0 deletions

View File

@ -6,6 +6,7 @@ class AdminDashboardData
GLOBAL_REPORTS ||= [
'visits',
'signups',
'profile_views',
'topics',
'posts',
'time_to_first_response',

View File

@ -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

View File

@ -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

View File

@ -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"