Skip to content

Commit

Permalink
Event reports byZone (#114)
Browse files Browse the repository at this point in the history
* Added event reports byZone

* Exposed zone on event and chart object info
  • Loading branch information
mroloux authored Jul 12, 2024
1 parent 5568408 commit 0d98fc1
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/seatsio/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class ChartObjectInfo

attr_reader :label, :labels, :ids, :category_key, :category_label, :section, :entrance, :capacity, :object_type,
:left_neighbour, :right_neighbour, :book_as_a_whole, :distance_to_focal_point, :num_seats, :is_accessible,
:is_companion_seat, :has_restricted_view
:is_companion_seat, :has_restricted_view, :zone

def initialize(data)
@label = data['label']
Expand All @@ -336,6 +336,7 @@ def initialize(data)
@is_accessible = data['isAccessible']
@is_companion_seat = data['isCompanionSeat']
@has_restricted_view = data['hasRestrictedView']
@zone = data['zone']
end
end

Expand Down Expand Up @@ -392,7 +393,8 @@ class EventObjectInfo
:is_accessible, :is_companion_seat, :has_restricted_view, :displayed_object_type,
:left_neighbour, :right_neighbour, :is_available, :channel,
:book_as_a_whole, :distance_to_focal_point, :holds, :num_seats, :variable_occupancy,
:min_occupancy, :max_occupancy, :season_status_overridden_quantity, :num_not_for_sale
:min_occupancy, :max_occupancy, :season_status_overridden_quantity, :num_not_for_sale,
:zone

def initialize(data)
@status = data['status']
Expand Down Expand Up @@ -430,6 +432,7 @@ def initialize(data)
@max_occupancy = data['maxOccupancy']
@season_status_overridden_quantity = data['seasonStatusOverriddenQuantity']
@num_not_for_sale = data['numNotForSale']
@zone = data['zone']
end
end

Expand Down
12 changes: 12 additions & 0 deletions lib/seatsio/event_reports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ def deep_summary_by_section(event_key)
fetch_deep_summary_report('bySection', event_key)
end

def by_zone(event_key, zone = nil)
fetch_report('byZone', event_key, zone)
end

def summary_by_zone(event_key)
fetch_summary_report('byZone', event_key)
end

def deep_summary_by_zone(event_key)
fetch_deep_summary_report('byZone', event_key)
end

def by_availability(event_key, availability = nil)
fetch_report('byAvailability', event_key, availability)
end
Expand Down
1 change: 1 addition & 0 deletions test/reports/charts/chart_reports_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def test_by_zone
report = get_report.(chart_key)
assert_equal(3, report.items.length)
assert_equal(6032, report.items['midtrack'].length)
assert_equal('midtrack', report.items['midtrack'][0].zone)
assert_equal(2865, report.items['finishline'].length)
assert_equal(0, report.items['NO_ZONE'].length)
end
Expand Down
10 changes: 10 additions & 0 deletions test/reports/events/event_reports_deep_summary_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ def test_deep_summary_by_section
assert_equal(1, report['NO_SECTION']['byCategoryLabel']['Cat1']['byAvailability']['not_available'])
end

def test_deep_summary_by_zone
chart_key = create_test_chart_with_zones
event = @seatsio.events.create chart_key: chart_key

report = @seatsio.event_reports.deep_summary_by_zone(event.key)

assert_equal(6032, report['midtrack']['count'])
assert_equal(6032, report['midtrack']['byCategoryLabel']['Mid Track Stand']['count'])
end

def test_deep_summary_by_availability
chart_key = create_test_chart
event = @seatsio.events.create chart_key: chart_key
Expand Down
11 changes: 11 additions & 0 deletions test/reports/events/event_reports_summary_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ def test_summary_by_section
assert_equal(116, report['NO_SECTION']['byCategoryLabel']['Cat1'])
assert_equal(116, report['NO_SECTION']['byCategoryLabel']['Cat2'])
assert_equal(232, report['NO_SECTION']['byChannel']['NO_CHANNEL'])
assert_equal(232, report['NO_SECTION']['byZone']['NO_ZONE'])
end

def test_summary_by_zone
chart_key = create_test_chart_with_zones
event = @seatsio.events.create chart_key: chart_key

report = @seatsio.event_reports.summary_by_zone(event.key)

assert_equal(6032, report['midtrack']['count'])
assert_equal(6032, report['midtrack']['byStatus']['free'])
end

def test_summary_by_availability
Expand Down
19 changes: 19 additions & 0 deletions test/reports/events/event_reports_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,25 @@ def test_by_specific_section
assert_equal(34, report.items.length)
end

def test_by_zone
chart_key = create_test_chart_with_zones
event = @seatsio.events.create chart_key: chart_key

report = @seatsio.event_reports.by_zone(event.key)

assert_equal(6032, report.items['midtrack'].length)
assert_equal('midtrack', report.items['midtrack'][0].zone)
end

def test_by_specific_zone
chart_key = create_test_chart_with_zones
event = @seatsio.events.create chart_key: chart_key

report = @seatsio.event_reports.by_zone(event.key, 'midtrack')

assert_equal(6032, report.items.length)
end

def test_by_availability
chart_key = create_test_chart
event = @seatsio.events.create chart_key: chart_key
Expand Down

0 comments on commit 0d98fc1

Please sign in to comment.