Skip to content

Commit

Permalink
Return teams by corner additionally in the match data
Browse files Browse the repository at this point in the history
See PeterJCLaw/srcomp#27 for more details.
  • Loading branch information
prophile authored and PeterJCLaw committed Aug 9, 2023
1 parent 3ad10e8 commit cf5fa57
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sr/comp/http/query_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,20 @@ def match_json_info(comp: SRComp, match: Match) -> MatchInfo:
match_slot_lengths = comp.schedule.match_slot_lengths
staging_times = comp.schedule.get_staging_times(match)

teams_by_corner = {
str(corner): team
for corner, team in zip(
comp.corners,
match.teams,
)
}

info = MatchInfo({
'num': match.num,
'display_name': match.display_name,
'arena': match.arena,
'teams': match.teams,
'teams_by_corner': teams_by_corner,
'type': match.type.value,
'times': {
'slot': {
Expand Down
42 changes: 42 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
'arena': 'A',
'type': 'league',
'teams': [None, 'CLY', 'TTN', None],
'teams_by_corner': {
'0': None,
'1': 'CLY',
'2': 'TTN',
'3': None,
},
'scores': {
'game': {'CLY': 9, 'TTN': 6},
'league': {'CLY': 8, 'TTN': 6},
Expand Down Expand Up @@ -51,6 +57,12 @@
'arena': 'B',
'type': 'league',
'teams': ['GRS', 'QMC', None, None],
'teams_by_corner': {
'0': 'GRS',
'1': 'QMC',
'2': None,
'3': None,
},
'scores': {
'game': {'QMC': 3, 'GRS': 5},
'league': {'QMC': 6, 'GRS': 8},
Expand Down Expand Up @@ -329,6 +341,12 @@ def test_matches(self) -> None:
'arena': 'A',
'type': 'league',
'teams': [None, 'CLY', 'TTN', None],
'teams_by_corner': {
'0': None,
'1': 'CLY',
'2': 'TTN',
'3': None,
},
'scores': {
'game': {'CLY': 9, 'TTN': 6},
'league': {'CLY': 8, 'TTN': 6},
Expand Down Expand Up @@ -371,6 +389,12 @@ def test_match_forwards_limit(self) -> None:
'arena': 'A',
'type': 'league',
'teams': [None, 'CLY', 'TTN', None],
'teams_by_corner': {
'0': None,
'1': 'CLY',
'2': 'TTN',
'3': None,
},
'scores': {
'game': {'CLY': 9, 'TTN': 6},
'league': {'CLY': 8, 'TTN': 6},
Expand Down Expand Up @@ -432,6 +456,12 @@ def test_match_backwards_limit(self) -> None:
},
},
'teams': ['???', '???', '???', '???'],
'teams_by_corner': {
'0': '???',
'1': '???',
'2': '???',
'3': '???',
},
},
],
'last_scored': 99,
Expand Down Expand Up @@ -469,6 +499,12 @@ def test_match_filter_naive_datetime(self) -> None:
},
},
'teams': ['???', '???', '???', '???'],
'teams_by_corner': {
'0': '???',
'1': '???',
'2': '???',
'3': '???',
},
},
],
'last_scored': 99,
Expand Down Expand Up @@ -514,6 +550,12 @@ def test_match_filter_time(self) -> None:
},
},
'teams': ['???', '???', '???', '???'],
'teams_by_corner': {
'0': '???',
'1': '???',
'2': '???',
'3': '???',
},
},
],
'last_scored': 99,
Expand Down

0 comments on commit cf5fa57

Please sign in to comment.