mirror of
https://github.com/discourse/discourse.git
synced 2025-06-14 19:29:21 +08:00
digest: don't show stats with 0. try to show new posts and new users counts.
This commit is contained in:
@ -101,10 +101,25 @@ class UserNotifications < ActionMailer::Base
|
|||||||
|
|
||||||
@preheader_text = I18n.t('user_notifications.digest.preheader', last_seen_at: @last_seen_at)
|
@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
|
# Try to find 3 interesting stats for the top of the digest
|
||||||
@unread_messages = user.unread_private_messages
|
@counts = [{label_key: 'user_notifications.digest.new_topics', value: Topic.new_since_last_seen(user, min_date).count}]
|
||||||
@unread_notifications = user.unread_notifications
|
|
||||||
|
|
||||||
|
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
|
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]
|
@popular_topics = topics_for_digest[0,SiteSetting.digest_topics]
|
||||||
|
@ -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>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="text-align:center;color:#fff;font-size:3em;font-weight:400;width:33%;">
|
<%- @counts.each do |count| -%>
|
||||||
<strong><%= @new_topics_count -%></strong>
|
<td style="text-align:center;color:#fff;font-size:3em;font-weight:400;">
|
||||||
</td>
|
<strong><%= count[:value] -%></strong>
|
||||||
<td style="text-align:center;color:#fff;font-size:3em;font-weight:400;">
|
</td>
|
||||||
<strong><%= @unread_messages -%></strong>
|
<%- end -%>
|
||||||
</td>
|
|
||||||
<td style="text-align:center;color:#fff;font-size:3em;font-weight:400;width:33%;">
|
|
||||||
<strong><%= @unread_notifications -%></strong>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="color:#fff;font-size:16px;font-weight:400;text-align:center;width:33%;">
|
<%- @counts.each do |count| -%>
|
||||||
<%=t 'user_notifications.digest.new_topics' %>
|
<td style="color:#fff;font-size:16px;font-weight:400;text-align:center;">
|
||||||
</td>
|
<strong><%=t count[:label_key] -%></strong>
|
||||||
<td style="color:#fff;font-size:16px;font-weight:400;text-align:center;">
|
</td>
|
||||||
<%=t 'user_notifications.digest.unread_messages' %>
|
<%- end -%>
|
||||||
</td>
|
|
||||||
<td style="color:#fff;font-size:16px;font-weight:400;text-align:center;width:33%;">
|
|
||||||
<%=t 'user_notifications.digest.unread_notifications' %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
site_link: site_link,
|
site_link: site_link,
|
||||||
last_seen_at: @last_seen_at) %>
|
last_seen_at: @last_seen_at) %>
|
||||||
|
|
||||||
<%= @new_topics_count -%> <%=t 'user_notifications.digest.new_topics' %>
|
<%- @counts.each do |count| -%>
|
||||||
<%= @unread_messages -%> <%=t 'user_notifications.digest.unread_messages' %>
|
<%= count[:value] -%> <%=t count[:label_key] %>
|
||||||
<%= @unread_notifications -%> <%=t 'user_notifications.digest.unread_notifications' %>
|
<%- end -%>
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -2432,6 +2432,8 @@ 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"
|
||||||
|
new_posts: "New Posts"
|
||||||
|
new_users: "New Users"
|
||||||
popular_topics: "Popular Topics"
|
popular_topics: "Popular Topics"
|
||||||
follow_topic: "Follow this topic"
|
follow_topic: "Follow this topic"
|
||||||
join_the_discussion: "Read More"
|
join_the_discussion: "Read More"
|
||||||
|
Reference in New Issue
Block a user