digest: don't show stats with 0. try to show new posts and new users counts.

This commit is contained in:
Neil Lalonde 2016-11-24 16:28:24 -05:00
parent 6c38053c32
commit 96daf5431f
4 changed files with 34 additions and 25 deletions

View File

@ -101,10 +101,25 @@ class UserNotifications < ActionMailer::Base
@preheader_text = I18n.t('user_notifications.digest.preheader', last_seen_at: @last_seen_at)
@new_topics_count = Topic.new_since_last_seen(user, min_date).count
@unread_messages = user.unread_private_messages
@unread_notifications = user.unread_notifications
# 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}]
value = user.unread_notifications
@counts << {label_key: 'user_notifications.digest.unread_notifications', value: value} if value > 0
value = user.unread_private_messages
@counts << {label_key: 'user_notifications.digest.unread_messages', value: value} 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}
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
end
# Now fetch some topics and posts to show
topics_for_digest = Topic.for_digest(user, min_date, limit: SiteSetting.digest_topics + 3, top_order: true).to_a
@popular_topics = topics_for_digest[0,SiteSetting.digest_topics]

View File

@ -58,29 +58,21 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
<table style="margin-bottom:20px;padding:0;vertical-align:top;width:100%">
<table style="table-layout:fixed;margin-bottom:20px;padding:0;vertical-align:top;width:100%">
<tbody>
<tr>
<td style="text-align:center;color:#fff;font-size:3em;font-weight:400;width:33%;">
<strong><%= @new_topics_count -%></strong>
</td>
<td style="text-align:center;color:#fff;font-size:3em;font-weight:400;">
<strong><%= @unread_messages -%></strong>
</td>
<td style="text-align:center;color:#fff;font-size:3em;font-weight:400;width:33%;">
<strong><%= @unread_notifications -%></strong>
</td>
<%- @counts.each do |count| -%>
<td style="text-align:center;color:#fff;font-size:3em;font-weight:400;">
<strong><%= count[:value] -%></strong>
</td>
<%- end -%>
</tr>
<tr>
<td style="color:#fff;font-size:16px;font-weight:400;text-align:center;width:33%;">
<%=t 'user_notifications.digest.new_topics' %>
</td>
<td style="color:#fff;font-size:16px;font-weight:400;text-align:center;">
<%=t 'user_notifications.digest.unread_messages' %>
</td>
<td style="color:#fff;font-size:16px;font-weight:400;text-align:center;width:33%;">
<%=t 'user_notifications.digest.unread_notifications' %>
</td>
<%- @counts.each do |count| -%>
<td style="color:#fff;font-size:16px;font-weight:400;text-align:center;">
<strong><%=t count[:label_key] -%></strong>
</td>
<%- end -%>
</tr>
</tbody>
</table>

View File

@ -3,9 +3,9 @@
site_link: site_link,
last_seen_at: @last_seen_at) %>
<%= @new_topics_count -%> <%=t 'user_notifications.digest.new_topics' %>
<%= @unread_messages -%> <%=t 'user_notifications.digest.unread_messages' %>
<%= @unread_notifications -%> <%=t 'user_notifications.digest.unread_notifications' %>
<%- @counts.each do |count| -%>
<%= count[:value] -%> <%=t count[:label_key] %>
<%- end -%>
--------------------------------------------------------------------------------

View File

@ -2432,6 +2432,8 @@ en:
new_topics: "New Topics"
unread_messages: "Unread Messages"
unread_notifications: "Unread Notifications"
new_posts: "New Posts"
new_users: "New Users"
popular_topics: "Popular Topics"
follow_topic: "Follow this topic"
join_the_discussion: "Read More"