mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
Add likes to admin dashboard
This commit is contained in:
parent
2665617271
commit
6a99d12784
@ -77,6 +77,7 @@
|
||||
{{ render 'admin_report_signups' signups }}
|
||||
{{ render 'admin_report_topics' topics }}
|
||||
{{ render 'admin_report_posts' posts }}
|
||||
{{ render 'admin_report_likes' likes }}
|
||||
{{ render 'admin_report_flags' flags }}
|
||||
{{/unless}}
|
||||
</table>
|
||||
|
@ -0,0 +1,4 @@
|
||||
Discourse.AdminReportLikesView = Discourse.View.extend({
|
||||
templateName: 'admin/templates/reports/summed_counts_report',
|
||||
tagName: 'tbody'
|
||||
});
|
@ -3,7 +3,7 @@ class Admin::DashboardController < Admin::AdminController
|
||||
|
||||
def index
|
||||
render_json_dump({
|
||||
reports: ['visits', 'signups', 'topics', 'posts', 'flags', 'users_by_trust_level'].map { |type| Report.find(type) },
|
||||
reports: ['visits', 'signups', 'topics', 'posts', 'flags', 'users_by_trust_level', 'likes'].map { |type| Report.find(type) },
|
||||
total_users: User.count
|
||||
}.merge(
|
||||
SiteSetting.version_checks? ? {version_check: DiscourseUpdates.check_version} : {}
|
||||
|
@ -50,6 +50,10 @@ class PostAction < ActiveRecord::Base
|
||||
user_actions
|
||||
end
|
||||
|
||||
def self.count_likes_per_day(since = 30.days.ago)
|
||||
where(post_action_type_id: PostActionType.types[:like]).where('created_at > ?', since).group('date(created_at)').order('date(created_at)').count
|
||||
end
|
||||
|
||||
def self.clear_flags!(post, moderator_id, action_type_id = nil)
|
||||
# -1 is the automatic system cleary
|
||||
actions = if action_type_id
|
||||
|
@ -89,6 +89,15 @@ class Report
|
||||
end
|
||||
end
|
||||
|
||||
def self.report_likes(report)
|
||||
report.data = []
|
||||
fetch report do
|
||||
PostAction.count_likes_per_day(30.days.ago).each do |date, count|
|
||||
report.data << {x: date, y: count}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
@ -263,12 +263,16 @@ en:
|
||||
title: "New Posts"
|
||||
xaxis: "Day"
|
||||
yaxis: "Number of new posts"
|
||||
likes:
|
||||
title: "New Likes"
|
||||
xaxis: "Day"
|
||||
yaxis: "Number of new likes"
|
||||
total_users:
|
||||
title: "Total Users"
|
||||
xaxis: "Day"
|
||||
yaxis: "Total number of users"
|
||||
flags:
|
||||
title: "Flags"
|
||||
title: "New Flags"
|
||||
xaxis: "Day"
|
||||
yaxis: "Number of flags"
|
||||
users_by_trust_level:
|
||||
|
5
spec/fabricators/like_fabricator.rb
Normal file
5
spec/fabricators/like_fabricator.rb
Normal file
@ -0,0 +1,5 @@
|
||||
Fabricator(:like, from: :post_action) do
|
||||
post
|
||||
user
|
||||
post_action_type_id PostActionType.types[:like]
|
||||
end
|
@ -26,7 +26,7 @@
|
||||
# end
|
||||
# end
|
||||
|
||||
# [:signup, :topic, :post, :flag].each do |arg|
|
||||
# [:signup, :topic, :post, :flag, :like].each do |arg|
|
||||
# describe "#{arg} report" do
|
||||
# pluralized = arg.to_s.pluralize
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user