FIX: in case of orphan user records skip badge

There are rare cases where orphan user records can exist, skip badges
This commit is contained in:
Sam Saffron 2019-08-30 17:21:34 +10:00
parent 17bed44405
commit ac7d68a745
1 changed files with 1 additions and 1 deletions

View File

@ -8,7 +8,7 @@
<description><![CDATA[<%= @rss_description %>]]></description> <description><![CDATA[<%= @rss_description %>]]></description>
<% if @badge.user_badges.first.present? %> <% if @badge.user_badges.first.present? %>
<atom:link href="<%= "#{@rss_link}.rss" %>" rel="self" type="application/rss+xml" /> <atom:link href="<%= "#{@rss_link}.rss" %>" rel="self" type="application/rss+xml" />
<% @badge.user_badges.last(50).reverse_each do |user_badge| %> <% @badge.user_badges.joins(:user).last(50).reverse_each do |user_badge| %>
<item> <item>
<title><![CDATA[<%= "@#{user_badge.user.username}#{" #{user_badge.user.name}" if (user_badge.user.name.present? && SiteSetting.enable_names?)}" -%>]]></title> <title><![CDATA[<%= "@#{user_badge.user.username}#{" #{user_badge.user.name}" if (user_badge.user.name.present? && SiteSetting.enable_names?)}" -%>]]></title>
<discourse:grantedAt><%= user_badge.granted_at.rfc2822 %></discourse:grantedAt> <discourse:grantedAt><%= user_badge.granted_at.rfc2822 %></discourse:grantedAt>