Skip to content

Commit

Permalink
Strip down the number of queries...
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Jan 9, 2025
1 parent 764d667 commit e3808ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
17 changes: 10 additions & 7 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ def show
@most_recent_cases = @cases[0...4].sort_by { |c| c.case_name.downcase }

@most_recent_books = recent_books(4)
@lookup_for_books = {}
@most_recent_books.each do |book|
judged_by_current_user = book.judgements.where(user: @current_user).count
if judged_by_current_user.positive? && judged_by_current_user < book.query_doc_pairs.size
@lookup_for_books[book] = book.query_doc_pairs.size - judged_by_current_user
end
end



# @lookup_for_books = {}
# @most_recent_books.each do |book|
# judged_by_current_user = book.judgements.where(user: @current_user).count
# if judged_by_current_user.positive? && judged_by_current_user < book.query_doc_pairs.size
# @lookup_for_books[book] = book.query_doc_pairs.size - judged_by_current_user
# end
# end

@most_recent_books = @most_recent_books.sort_by { |b| b.name.downcase }

Expand Down
5 changes: 1 addition & 4 deletions app/views/home/_book_summary.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
</p>
<span id="notification-book-<%= book.id %>">
</span>
<!-- Look at https://github.com/ankane/prophet-ruby -->
<% if @lookup_for_books[book] && @lookup_for_books[book] > 0 %>
<p class="card-text text-danger"><i class="frog-icon" aria-hidden="true">🐸</i> You need to judge <%= @lookup_for_books[book] %> out <%= book.query_doc_pairs.size %> query/doc pairs.</p>
<% end %>

<%= link_to 'Judge', book_judge_path(book), data: { turbo_prefetch: false }, class: 'btn btn-sm btn-primary', role: 'button' %>
</div>
</div>
Expand Down

0 comments on commit e3808ad

Please sign in to comment.