Show how many likes users received in the last 100 days on their admin profile page
This commit is contained in:
parent
300dbdc88b
commit
dafc63e3a0
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue