Counts at top of summary email are links

This commit is contained in:
Neil Lalonde 2016-11-29 17:10:25 -05:00
parent ae38a78bb6
commit a187932126
2 changed files with 17 additions and 7 deletions

View File

@ -102,21 +102,31 @@ class UserNotifications < ActionMailer::Base
@preheader_text = I18n.t('user_notifications.digest.preheader', last_seen_at: @last_seen_at)
# Try to find 3 interesting stats for the top of the digest
@counts = [{label_key: 'user_notifications.digest.new_topics', value: Topic.new_since_last_seen(user, min_date).count}]
@counts = [{label_key: 'user_notifications.digest.new_topics',
value: Topic.new_since_last_seen(user, min_date).count,
href: "#{Discourse.base_url}/new"}]
value = user.unread_notifications
@counts << {label_key: 'user_notifications.digest.unread_notifications', value: value} if value > 0
@counts << {label_key: 'user_notifications.digest.unread_notifications', value: value, href: "#{Discourse.base_url}/my/notifications"} if value > 0
value = user.unread_private_messages
@counts << {label_key: 'user_notifications.digest.unread_messages', value: value} 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
@counts << {label_key: 'user_notifications.digest.new_posts', value: Post.for_mailing_list(user, min_date).where("posts.post_number > ?", 1).count}
@counts << {
label_key: 'user_notifications.digest.new_posts',
value: Post.for_mailing_list(user, min_date).where("posts.post_number > ?", 1).count,
href: "#{Discourse.base_url}/new"
}
end
if @counts.size < 3
value = User.real.where(active: true, staged: false).not_suspended.where("created_at > ?", min_date).count
@counts << {label_key: 'user_notifications.digest.new_users', value: value } if value > 0
@counts << {
label_key: 'user_notifications.digest.new_users',
value: value,
href: "#{Discourse.base_url}/about"
} if value > 0
end
# Now fetch some topics and posts to show

View File

@ -63,14 +63,14 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
<tr>
<%- @counts.each do |count| -%>
<td style="text-align:center;color:#fff;font-size:3em;font-weight:400;">
<strong><%= count[:value] -%></strong>
<a style="color:#fff;" href="<%= count[:href] -%>"><strong><%= count[:value] -%></strong></a>
</td>
<%- end -%>
</tr>
<tr>
<%- @counts.each do |count| -%>
<td style="color:#fff;font-size:16px;font-weight:400;text-align:center;">
<strong><%=t count[:label_key] -%></strong>
<a style="color:#fff;" href="<%= count[:href] -%>"><strong><%=t count[:label_key] -%></strong></a>
</td>
<%- end -%>
</tr>