Skip to content

Commit

Permalink
Replace exists? with check for count
Browse files Browse the repository at this point in the history
  • Loading branch information
norrismei committed Sep 22, 2024
1 parent 71b84d7 commit a643e2a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def index
.undiscarded
.during(helpers.selected_range)
.class_filter(filter_params)
@unfulfilled_requests = current_organization.requests.where(status: [:pending, :started])
@unfulfilled_requests_count = current_organization.requests.where(status: [:pending, :started]).count
@paginated_requests = @requests.page(params[:page])
@calculate_product_totals = RequestsTotalItemsService.new(requests: @requests).calculate
@items = current_organization.items.alphabetized
Expand Down
4 changes: 2 additions & 2 deletions app/views/requests/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
<%= clear_filter_button %>
<%= modal_button_to("#calculateTotals", {text: "Calculate Product Totals", icon: nil, size: "md", type: "success"}) %>
<span class="float-right">
<% if @unfulfilled_requests.exists? %>
<% if @unfulfilled_requests_count > 0 %>
<%= print_button_to(
print_unfulfilled_requests_path(format: :pdf),
text: "Print Unfulfilled Picklists (#{@unfulfilled_requests.size})",
text: "Print Unfulfilled Picklists (#{@unfulfilled_requests_count})",
size: "md") %>
<% end %>
<%= download_button_to(requests_path(format: :csv, filters: filter_params.merge(date_range: date_range_params)), {text: "Export Requests", size: "md"}) if @requests.any? %>
Expand Down

0 comments on commit a643e2a

Please sign in to comment.