amatriain/feedbunch

View on GitHub
FeedBunch-app/app/views/api/entries/index.json.erb

Summary

Maintainability
Test Coverage
[
<% first_entry = true %>
<% @entries.each do |entry| %>
  <% begin %>
    <%# If list doesn't include read entries, skip looking at the DB for the entry state, we already know it is unread. Better performance this way. %>
    <% if @include_read %>
      <% read = entry.read_by? @user %>
    <% else %>
      <% read = false %>
    <% end %>
    <% if !first_entry %>
,
    <% end %>
    <%= render partial: 'api/entries/entry', locals: {entry: entry, read: read} %>
    <% first_entry = false %>
  <% rescue NotSubscribedError %>
    <%# If the feed has just been unsubscribed, a NotSubscribedError will be raised. Ignore this entry and
     continue with the next one%>
  <% end %>
<% end %>
]