Skip to content

Commit

Permalink
cleanup ticket requests listings
Browse files Browse the repository at this point in the history
  • Loading branch information
beingmattlevy committed Jul 30, 2024
1 parent 8b75220 commit 0c9d947
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/controllers/ticket_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def index
requests: requests.count,
adults: requests.sum(&:adults),
kids: requests.sum(&:kids),
addon_passes: requests.sum(&:active_addon_pass_count),
addon_camping: requests.sum(&:active_addon_camp_count),
addon_passes: requests.sum(&:active_addon_pass_sum),
addon_camping: requests.sum(&:active_addon_camp_sum),
raised: requests.sum(&:price)
}
end
Expand Down
16 changes: 10 additions & 6 deletions app/models/ticket_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,20 +357,24 @@ def active_addons
ticket_request_event_addons.where('quantity > ?', 0)
end

def active_addons_sum
active_addons.sum { |a| a.quantity }
end

def active_sorted_addons
active_addons.sort_by { |e| [e.category, e.price, e.name] }
end

def active_addon_pass_count
@active_addon_pass_count ||= active_addon_by_category(Addon::CATEGORY_PASS).count
def active_addon_pass_sum
active_addon_sum_quantity_by_category(Addon::CATEGORY_PASS)
end

def active_addon_camp_count
@active_addon_camp_count ||= active_addon_by_category(Addon::CATEGORY_CAMP).count
def active_addon_camp_sum
active_addon_sum_quantity_by_category(Addon::CATEGORY_CAMP)
end

def active_addon_by_category(category)
active_addons.select { |addon| addon.category == category }
def active_addon_sum_quantity_by_category(category)
active_addons.select { |addon| addon.category == category }.sum { |a| a.quantity }
end

def ticket_request_event_addons?
Expand Down
10 changes: 5 additions & 5 deletions app/views/ticket_requests/_table_ticket_requests.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
- if ticket_request.needs_assistance
= tooltip_box('Financial Assistance was requested.') do
= image_tag('icons/dollar.png', width: 20, class: 'hover-tooltip')
- if ticket_request.active_addon_camp_count
= tooltip_box(ticket_request.active_addon_camp_count, title: "Camping:") do
- if ticket_request.active_addon_camp_sum
= tooltip_box(ticket_request.active_addon_camp_sum, title: "Camping:") do
= image_tag('icons/car.png', width: 20, class: 'hover-tooltip')
- if ticket_request.active_addon_pass_count
= tooltip_box(ticket_request.active_addon_pass_count, title: "Passes:") do
- if ticket_request.active_addon_pass_sum
= tooltip_box(ticket_request.active_addon_pass_sum, title: "Passes:") do
= image_tag('icons/pass.png', width: 20, class: 'hover-tooltip')
- if ticket_request.admin_notes.present?
= tooltip_box(ticket_request.admin_notes, title: "Admin Notes") do
Expand All @@ -57,7 +57,7 @@
%td.align-content-center.text-end.optional-medium= ticket_request.kids
- if event.active_event_addons?
%td.align-content-center.text-end.optional-medium= ticket_request.active_addons.count
%td.align-content-center.text-end.optional-medium= ticket_request.active_addons_sum
%td.align-content-center.text-end
%span{ class: ('label label-info' if ticket_request.special_price) }
Expand Down

0 comments on commit 0c9d947

Please sign in to comment.