Skip to content

Commit 1709cee

Browse files
committed
feature: allow for tournament team tags
1 parent 89772ed commit 1709cee

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

src/matches/matches.controller.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,20 @@ export class MatchesController {
191191
},
192192
},
193193
},
194+
tournament_brackets: {
195+
team_1: {
196+
name: true,
197+
team: {
198+
short_name: true,
199+
},
200+
},
201+
team_2: {
202+
name: true,
203+
team: {
204+
short_name: true,
205+
},
206+
},
207+
},
194208
},
195209
});
196210

@@ -263,7 +277,13 @@ export class MatchesController {
263277
}
264278
}
265279

266-
match.lineup_1.tag = match.lineup_1.team?.short_name;
280+
const tournamentBracket = match.tournament_brackets?.at(0);
281+
const lineup1TournamentTag =
282+
tournamentBracket?.team_1?.team?.short_name || tournamentBracket?.team_1?.name;
283+
const lineup2TournamentTag =
284+
tournamentBracket?.team_2?.team?.short_name || tournamentBracket?.team_2?.name;
285+
286+
match.lineup_1.tag = lineup1TournamentTag || match.lineup_1.team?.short_name;
267287
delete match.lineup_1.team;
268288
match.lineup_1.lineup_players = match.lineup_1.lineup_players.map(
269289
(player) => ({
@@ -277,7 +297,7 @@ export class MatchesController {
277297
}),
278298
);
279299

280-
match.lineup_2.tag = match.lineup_2.team?.short_name;
300+
match.lineup_2.tag = lineup2TournamentTag || match.lineup_2.team?.short_name;
281301
delete match.lineup_2.team;
282302
match.lineup_2.lineup_players = match.lineup_2.lineup_players.map(
283303
(player) => ({

0 commit comments

Comments
 (0)