Skip to content

Commit

Permalink
Added chart report by zone (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored Jul 12, 2024
1 parent e0f0fb0 commit 5568408
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/seatsio/chart_reports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ def summary_by_section(event_key, book_whole_tables = nil, version = nil)
fetch_summary_report('bySection', event_key, book_whole_tables, version)
end

def by_zone(chart_key, book_whole_tables = nil, version = nil)
fetch_chart_report('byZone', chart_key, book_whole_tables, version)
end

def summary_by_zone(event_key, book_whole_tables = nil, version = nil)
fetch_summary_report('byZone', event_key, book_whole_tables, version)
end

private

def fetch_chart_report(report_type, chart_key, book_whole_tables, version)
Expand Down
19 changes: 19 additions & 0 deletions test/reports/charts/chart_reports_summary_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ def test_summary_by_section
end
end

def test_summary_by_zone
[
[-> (_) { }, -> (chart_key) { @seatsio.chart_reports.summary_by_zone(chart_key) }],
[-> (chart_key) { create_draft_version chart_key }, -> (chart_key) { @seatsio.chart_reports.summary_by_zone(chart_key, nil, 'draft') }]
].each do |update_chart, get_report|
chart_key = create_test_chart_with_zones
update_chart.(chart_key)

report = get_report.(chart_key)

assert_equal(6032, report['midtrack']['count'])
assert_equal(6032, report['midtrack']['byCategoryKey']['2'])
assert_equal(6032, report['midtrack']['byCategoryLabel']['Mid Track Stand'])
assert_equal(6032, report['midtrack']['byObjectType']['seat'])
assert_equal(2418, report['midtrack']['bySection']['MT1'])
assert_equal(3614, report['midtrack']['bySection']['MT3'])
end
end

private def create_draft_version(chart_key)
@seatsio.events.create chart_key: chart_key
@seatsio.charts.update key: chart_key, new_name: 'foo'
Expand Down
16 changes: 16 additions & 0 deletions test/reports/charts/chart_reports_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,22 @@ def test_by_section
end
end

def test_by_zone
[
[-> (_) { }, -> (chart_key) { @seatsio.chart_reports.by_zone(chart_key) }],
[-> (chart_key) { create_draft_version chart_key }, -> (chart_key) { @seatsio.chart_reports.by_zone(chart_key, nil, 'draft') }]
].each do |update_chart, get_report|
chart_key = create_test_chart_with_zones
update_chart.(chart_key)

report = get_report.(chart_key)
assert_equal(3, report.items.length)
assert_equal(6032, report.items['midtrack'].length)
assert_equal(2865, report.items['finishline'].length)
assert_equal(0, report.items['NO_ZONE'].length)
end
end

def test_with_extra_data
chart_key = create_test_chart
event1 = @seatsio.events.create chart_key: chart_key
Expand Down
1 change: 1 addition & 0 deletions test/sampleChartWithZones.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions test/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def create_test_chart

def create_test_chart_with_sections
create_test_chart_from_file('sampleChartWithSections.json')
end

def create_test_chart_with_zones
create_test_chart_from_file('sampleChartWithZones.json')
end

def create_test_chart_with_tables
Expand Down

0 comments on commit 5568408

Please sign in to comment.