feat(match-service): enhance team identification logic and update league table display
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 57s
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 57s
This commit is contained in:
@@ -655,6 +655,28 @@ class MatchService {
|
||||
order: [['id', 'ASC']]
|
||||
});
|
||||
|
||||
// Do not rely solely on the club name for identifying our teams.
|
||||
// A club can have several explicitly configured teams whose click-TT
|
||||
// names differ from the club name.
|
||||
const [club, configuredClubTeams] = await Promise.all([
|
||||
Club.findByPk(clubId, { attributes: ['name'] }),
|
||||
ClubTeam.findAll({
|
||||
where: { clubId, leagueId },
|
||||
attributes: ['name']
|
||||
})
|
||||
]);
|
||||
const configuredTeamNames = new Set(
|
||||
configuredClubTeams.map((team) => this.normalizeTeamNameForMatch(team.name))
|
||||
);
|
||||
const ownTeamIds = new Set(
|
||||
teams
|
||||
.filter((team) =>
|
||||
this.isTeamNameForClub(team.name, club?.name) ||
|
||||
configuredTeamNames.has(this.normalizeTeamNameForMatch(team.name))
|
||||
)
|
||||
.map((team) => team.id)
|
||||
);
|
||||
|
||||
// A table-points result is ranked by its balance, not just by the
|
||||
// number of points won: 0:0 (0) must therefore rank ahead of 0:2
|
||||
// (-2), which in turn ranks ahead of 0:4 (-4).
|
||||
@@ -676,6 +698,7 @@ class MatchService {
|
||||
return {
|
||||
teamId: team.id,
|
||||
teamName: team.name,
|
||||
isOwnTeam: ownTeamIds.has(team.id),
|
||||
setsWon: team.setsWon,
|
||||
setsLost: team.setsLost,
|
||||
matchPoints: team.matchesWon + ':' + team.matchesLost,
|
||||
|
||||
Reference in New Issue
Block a user