mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 18:13:39 +08:00
add Likes Recieved to possible stats in summary email
This commit is contained in:
parent
70227d37d7
commit
239d06b218
|
@ -112,6 +112,11 @@ class UserNotifications < ActionMailer::Base
|
|||
value = user.unread_private_messages
|
||||
@counts << {label_key: 'user_notifications.digest.unread_messages', value: value, href: "#{Discourse.base_url}/my/messages"} if value > 0
|
||||
|
||||
if @counts.size < 3
|
||||
value = user.unread_notifications_of_type(Notification.types[:liked])
|
||||
@counts << {label_key: 'user_notifications.digest.liked_received', value: value, href: "#{Discourse.base_url}/my/notifications"} if value > 0
|
||||
end
|
||||
|
||||
if @counts.size < 3
|
||||
@counts << {
|
||||
label_key: 'user_notifications.digest.new_posts',
|
||||
|
|
|
@ -293,23 +293,22 @@ class User < ActiveRecord::Base
|
|||
super
|
||||
end
|
||||
|
||||
def unread_private_messages
|
||||
@unread_pms ||=
|
||||
begin
|
||||
# perf critical, much more efficient than AR
|
||||
sql = "
|
||||
SELECT COUNT(*) FROM notifications n
|
||||
LEFT JOIN topics t ON n.topic_id = t.id
|
||||
WHERE
|
||||
t.deleted_at IS NULL AND
|
||||
n.notification_type = :type AND
|
||||
n.user_id = :user_id AND
|
||||
NOT read"
|
||||
def unread_notifications_of_type(notification_type)
|
||||
# perf critical, much more efficient than AR
|
||||
sql = "
|
||||
SELECT COUNT(*) FROM notifications n
|
||||
LEFT JOIN topics t ON n.topic_id = t.id
|
||||
WHERE
|
||||
t.deleted_at IS NULL AND
|
||||
n.notification_type = :type AND
|
||||
n.user_id = :user_id AND
|
||||
NOT read"
|
||||
|
||||
User.exec_sql(sql, user_id: id,
|
||||
type: Notification.types[:private_message])
|
||||
.getvalue(0,0).to_i
|
||||
end
|
||||
User.exec_sql(sql, user_id: id, type: notification_type).getvalue(0,0).to_i
|
||||
end
|
||||
|
||||
def unread_private_messages
|
||||
@unread_pms ||= unread_notifications_of_type(Notification.types[:private_message])
|
||||
end
|
||||
|
||||
def unread_notifications
|
||||
|
|
|
@ -2448,6 +2448,7 @@ en:
|
|||
new_topics: "New Topics"
|
||||
unread_messages: "Unread Messages"
|
||||
unread_notifications: "Unread Notifications"
|
||||
liked_received: "Likes Received"
|
||||
new_posts: "New Posts"
|
||||
new_users: "New Users"
|
||||
popular_topics: "Popular Topics"
|
||||
|
|
Loading…
Reference in New Issue
Block a user