Show how many likes users received in the last 100 days on their admin profile page

This commit is contained in:
Neil Lalonde 2014-08-22 14:37:00 -04:00
parent 300dbdc88b
commit dafc63e3a0
4 changed files with 11 additions and 0 deletions

View File

@ -321,6 +321,7 @@
<div class='display-row'>
<div class='field'>{{i18n admin.user.like_count}}</div>
<div class='value'>{{like_count}}</div>
<div class='controls'>{{like_count_last_100_days}} {{i18n admin.user.last_100_days}}</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n admin.user.topics_entered}}</div>

View File

@ -375,6 +375,10 @@ class User < ActiveRecord::Base
UserAction.where(user_id: id, action_type: UserAction::WAS_LIKED).count
end
def like_count_since(time)
UserAction.where(user_id: id, action_type: UserAction::WAS_LIKED).where('created_at > ?', time).count
end
def post_count
stat = user_stat || create_user_stat
stat.post_count

View File

@ -7,6 +7,7 @@ class AdminDetailedUserSerializer < AdminUserSerializer
:can_revoke_moderation,
:can_impersonate,
:like_count,
:like_count_last_100_days,
:post_count,
:topic_count,
:flags_given_count,
@ -52,6 +53,10 @@ class AdminDetailedUserSerializer < AdminUserSerializer
object.moderator
end
def like_count_last_100_days
object.like_count_since(100.days.ago)
end
def topic_count
object.topics.count
end

View File

@ -1880,6 +1880,7 @@ en:
permissions: Permissions
activity: Activity
like_count: Likes Received
last_100_days: 'in the last 100 days'
private_topics_count: Private Topics
posts_read_count: Posts Read
post_count: Posts Created