volleyballsimtypes 0.0.449 → 0.0.451
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -33,14 +33,17 @@ function transformToAttributes(season) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
function transformToObject(model) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const teams = (0, _1.sortTeamsByCompetitionIndex)(model.Teams ?? []).map(_1.transformToTeam);
|
|
37
|
+
// One standing per roster team: the persisted CompetitionStandings aggregate where it exists, a zero-stat
|
|
38
|
+
// row otherwise. CompetitionStandings only gains a row once a team plays (the DB trigger fires on match
|
|
39
|
+
// COMPLETE), so mapping it directly dropped un-played teams from the table for the first part of a season.
|
|
40
|
+
const standingByTeam = new Map((model.CompetitionStandings ?? []).map(s => [s.team_id, (0, _1.transformToStanding)(s)]));
|
|
41
|
+
const standings = teams.map(t => standingByTeam.get(t.id) ?? service_1.Standing.create({ teamId: t.id }));
|
|
39
42
|
return service_1.Season.create({
|
|
40
43
|
id: model.competition_id,
|
|
41
44
|
matches: (model.CompetitionMatches ?? []).map((matches) => (0, _1.transformToMatch)(matches.Match)),
|
|
42
45
|
iteration: (0, _1.transformToIteration)(model.Iteration),
|
|
43
|
-
teams
|
|
46
|
+
teams,
|
|
44
47
|
champion: model.CompetitionChampion != null ? (0, _1.transformToTeam)(model.CompetitionChampion.team) : undefined,
|
|
45
48
|
status: model.status,
|
|
46
49
|
divisionId: model.DivisionSeason.division_id,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sortTeamsByCompetitionIndex, transformFromSeasonMatch, transformToIteration, transformToMatch, transformToStanding, transformToTeam } from '.';
|
|
2
|
-
import { Season } from '../../service';
|
|
2
|
+
import { Season, Standing } from '../../service';
|
|
3
3
|
function transformToAttributes(season) {
|
|
4
4
|
const matches = (season.matches ?? []).map((match, index) => transformFromSeasonMatch(season.id, match, index));
|
|
5
5
|
const teams = season.teams.map((team, index) => ({
|
|
@@ -29,14 +29,17 @@ function transformToAttributes(season) {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
function transformToObject(model) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const teams = sortTeamsByCompetitionIndex(model.Teams ?? []).map(transformToTeam);
|
|
33
|
+
// One standing per roster team: the persisted CompetitionStandings aggregate where it exists, a zero-stat
|
|
34
|
+
// row otherwise. CompetitionStandings only gains a row once a team plays (the DB trigger fires on match
|
|
35
|
+
// COMPLETE), so mapping it directly dropped un-played teams from the table for the first part of a season.
|
|
36
|
+
const standingByTeam = new Map((model.CompetitionStandings ?? []).map(s => [s.team_id, transformToStanding(s)]));
|
|
37
|
+
const standings = teams.map(t => standingByTeam.get(t.id) ?? Standing.create({ teamId: t.id }));
|
|
35
38
|
return Season.create({
|
|
36
39
|
id: model.competition_id,
|
|
37
40
|
matches: (model.CompetitionMatches ?? []).map((matches) => transformToMatch(matches.Match)),
|
|
38
41
|
iteration: transformToIteration(model.Iteration),
|
|
39
|
-
teams
|
|
42
|
+
teams,
|
|
40
43
|
champion: model.CompetitionChampion != null ? transformToTeam(model.CompetitionChampion.team) : undefined,
|
|
41
44
|
status: model.status,
|
|
42
45
|
divisionId: model.DivisionSeason.division_id,
|