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
|
value = user.unread_private_messages
|
||||||
@counts << {label_key: 'user_notifications.digest.unread_messages', value: value, href: "#{Discourse.base_url}/my/messages"} if value > 0
|
@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
|
if @counts.size < 3
|
||||||
@counts << {
|
@counts << {
|
||||||
label_key: 'user_notifications.digest.new_posts',
|
label_key: 'user_notifications.digest.new_posts',
|
||||||
|
|
|
@ -293,23 +293,22 @@ class User < ActiveRecord::Base
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def unread_private_messages
|
def unread_notifications_of_type(notification_type)
|
||||||
@unread_pms ||=
|
# perf critical, much more efficient than AR
|
||||||
begin
|
sql = "
|
||||||
# perf critical, much more efficient than AR
|
SELECT COUNT(*) FROM notifications n
|
||||||
sql = "
|
LEFT JOIN topics t ON n.topic_id = t.id
|
||||||
SELECT COUNT(*) FROM notifications n
|
WHERE
|
||||||
LEFT JOIN topics t ON n.topic_id = t.id
|
t.deleted_at IS NULL AND
|
||||||
WHERE
|
n.notification_type = :type AND
|
||||||
t.deleted_at IS NULL AND
|
n.user_id = :user_id AND
|
||||||
n.notification_type = :type AND
|
NOT read"
|
||||||
n.user_id = :user_id AND
|
|
||||||
NOT read"
|
|
||||||
|
|
||||||
User.exec_sql(sql, user_id: id,
|
User.exec_sql(sql, user_id: id, type: notification_type).getvalue(0,0).to_i
|
||||||
type: Notification.types[:private_message])
|
end
|
||||||
.getvalue(0,0).to_i
|
|
||||||
end
|
def unread_private_messages
|
||||||
|
@unread_pms ||= unread_notifications_of_type(Notification.types[:private_message])
|
||||||
end
|
end
|
||||||
|
|
||||||
def unread_notifications
|
def unread_notifications
|
||||||
|
|
|
@ -2448,6 +2448,7 @@ en:
|
||||||
new_topics: "New Topics"
|
new_topics: "New Topics"
|
||||||
unread_messages: "Unread Messages"
|
unread_messages: "Unread Messages"
|
||||||
unread_notifications: "Unread Notifications"
|
unread_notifications: "Unread Notifications"
|
||||||
|
liked_received: "Likes Received"
|
||||||
new_posts: "New Posts"
|
new_posts: "New Posts"
|
||||||
new_users: "New Users"
|
new_users: "New Users"
|
||||||
popular_topics: "Popular Topics"
|
popular_topics: "Popular Topics"
|
||||||
|
|
Loading…
Reference in New Issue