volleyballsimtypes 0.0.202 → 0.0.204

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.
Files changed (41) hide show
  1. package/dist/cjs/src/data/init-models.js +8 -1
  2. package/dist/cjs/src/data/models/index.d.ts +1 -1
  3. package/dist/cjs/src/data/models/index.js +1 -1
  4. package/dist/cjs/src/data/models/team.js +6 -1
  5. package/dist/cjs/src/data/models/views/box-score-totals.d.ts +71 -0
  6. package/dist/cjs/src/data/models/views/box-score-totals.js +138 -0
  7. package/dist/cjs/src/data/models/views/historic-standings.d.ts +51 -0
  8. package/dist/cjs/src/data/models/views/historic-standings.js +56 -0
  9. package/dist/cjs/src/data/models/views/index.d.ts +3 -0
  10. package/dist/cjs/src/data/models/views/index.js +19 -0
  11. package/dist/cjs/src/data/models/{match-result.d.ts → views/match-result.d.ts} +5 -5
  12. package/dist/cjs/src/data/models/{match-result.js → views/match-result.js} +1 -1
  13. package/dist/cjs/src/data/transformers/match.js +1 -1
  14. package/dist/cjs/src/service/competition/season.d.ts +0 -1
  15. package/dist/cjs/src/service/competition/season.js +0 -9
  16. package/dist/cjs/src/service/competition/standing.js +2 -6
  17. package/dist/cjs/src/service/match/match.d.ts +3 -9
  18. package/dist/cjs/src/service/match/match.js +5 -11
  19. package/dist/cjs/src/service/match/rally.d.ts +1 -4
  20. package/dist/cjs/src/service/match/rally.js +1 -2
  21. package/dist/esm/src/data/init-models.js +9 -2
  22. package/dist/esm/src/data/models/index.d.ts +1 -1
  23. package/dist/esm/src/data/models/index.js +1 -1
  24. package/dist/esm/src/data/models/team.js +7 -2
  25. package/dist/esm/src/data/models/views/box-score-totals.d.ts +71 -0
  26. package/dist/esm/src/data/models/views/box-score-totals.js +134 -0
  27. package/dist/esm/src/data/models/views/historic-standings.d.ts +51 -0
  28. package/dist/esm/src/data/models/views/historic-standings.js +52 -0
  29. package/dist/esm/src/data/models/views/index.d.ts +3 -0
  30. package/dist/esm/src/data/models/views/index.js +3 -0
  31. package/dist/esm/src/data/models/{match-result.d.ts → views/match-result.d.ts} +5 -5
  32. package/dist/esm/src/data/models/{match-result.js → views/match-result.js} +1 -1
  33. package/dist/esm/src/data/transformers/match.js +1 -1
  34. package/dist/esm/src/service/competition/season.d.ts +0 -1
  35. package/dist/esm/src/service/competition/season.js +0 -9
  36. package/dist/esm/src/service/competition/standing.js +2 -6
  37. package/dist/esm/src/service/match/match.d.ts +3 -9
  38. package/dist/esm/src/service/match/match.js +4 -10
  39. package/dist/esm/src/service/match/rally.d.ts +1 -4
  40. package/dist/esm/src/service/match/rally.js +1 -2
  41. package/package.json +1 -1
@@ -15,11 +15,13 @@ function initModels(sequelize) {
15
15
  const League = models_1.LeagueModel.initModel(sequelize);
16
16
  const Division = models_1.DivisionModel.initModel(sequelize);
17
17
  const DivisionSeason = models_1.DivisionSeasonModel.initModel(sequelize);
18
+ const HistoricStandings = models_1.HistoricStandingsModel.initModel(sequelize);
18
19
  const Match = models_1.MatchModel.initModel(sequelize);
19
20
  const MatchRating = models_1.MatchRatingModel.initModel(sequelize);
20
21
  const MatchResult = models_1.MatchResultModel.initModel(sequelize);
21
22
  const MatchSet = models_1.MatchSetModel.initModel(sequelize);
22
23
  const BoxScore = models_1.BoxScoreModel.initModel(sequelize);
24
+ const BoxScoreTotals = models_1.BoxScoreTotalsModel.initModel(sequelize);
23
25
  const PerformanceStats = models_1.PerformanceStatsModel.initModel(sequelize);
24
26
  const Player = models_1.PlayerModel.initModel(sequelize);
25
27
  const PlayerTeam = models_1.PlayerTeamModel.initModel(sequelize);
@@ -59,6 +61,8 @@ function initModels(sequelize) {
59
61
  Division.hasMany(Team, { as: 'Teams', foreignKey: 'division_id' });
60
62
  DivisionSeason.belongsTo(Competition, { as: 'competition', foreignKey: 'competition_id' });
61
63
  DivisionSeason.belongsTo(Division, { as: 'division', foreignKey: 'division_id' });
64
+ HistoricStandings.belongsTo(Competition, { as: 'Competition', foreignKey: 'competition_id' });
65
+ HistoricStandings.belongsTo(Team, { as: 'Team', foreignKey: 'team_id' });
62
66
  Team.belongsTo(Division, { as: 'Division', foreignKey: 'division_id' });
63
67
  Match.belongsTo(Team, { as: 'AwayTeam', foreignKey: 'away_team' });
64
68
  Match.belongsTo(Team, { as: 'HomeTeam', foreignKey: 'home_team' });
@@ -73,7 +77,7 @@ function initModels(sequelize) {
73
77
  Match.hasOne(CompetitionMatch, { as: 'CompetitionMatch', foreignKey: 'match_id' });
74
78
  Match.hasOne(MatchResult, { as: 'MatchResult', foreignKey: 'match_id' });
75
79
  MatchResult.belongsTo(Match, { as: 'Match', foreignKey: 'match_id' });
76
- MatchResult.belongsTo(Team, { as: 'WinnerTeam', foreignKey: 'winner_team_id' });
80
+ MatchResult.belongsTo(Team, { as: 'Winner', foreignKey: 'winner_team_id' });
77
81
  MatchRating.belongsTo(Match, { as: 'match', foreignKey: 'match_id' });
78
82
  MatchRating.belongsTo(Team, { as: 'team', foreignKey: 'team_id' });
79
83
  MatchSet.belongsTo(Match, { as: 'match', foreignKey: 'match_id' });
@@ -87,6 +91,7 @@ function initModels(sequelize) {
87
91
  MatchSet.hasMany(Rally, { as: 'Rallies', foreignKey: 'match_set_id' });
88
92
  BoxScore.belongsTo(MatchSet, { as: 'MatchSet', foreignKey: 'match_set_id' });
89
93
  BoxScore.belongsTo(Player, { as: 'Player', foreignKey: 'player_id' });
94
+ BoxScoreTotals.belongsTo(Player, { as: 'Player', foreignKey: 'player_id' });
90
95
  PerformanceStats.belongsTo(Player, { as: 'player', foreignKey: 'player_id' });
91
96
  Player.belongsTo(Country, { as: 'country', foreignKey: 'country_id' });
92
97
  Player.belongsToMany(MatchSet, {
@@ -150,11 +155,13 @@ function initModels(sequelize) {
150
155
  Iteration,
151
156
  League,
152
157
  DivisionSeason,
158
+ HistoricStandings,
153
159
  Match,
154
160
  MatchRating,
155
161
  MatchResult,
156
162
  MatchSet,
157
163
  BoxScore,
164
+ BoxScoreTotals,
158
165
  PerformanceStats,
159
166
  Player,
160
167
  PlayerTeam,
@@ -12,7 +12,6 @@ export * from './division';
12
12
  export * from './division-season';
13
13
  export * from './match';
14
14
  export * from './match-rating';
15
- export * from './match-result';
16
15
  export * from './match-set';
17
16
  export * from './performance-stats';
18
17
  export * from './player';
@@ -21,3 +20,4 @@ export * from './rally';
21
20
  export * from './team';
22
21
  export * from './user';
23
22
  export * from './tactics';
23
+ export * from './views';
@@ -28,7 +28,6 @@ __exportStar(require("./division"), exports);
28
28
  __exportStar(require("./division-season"), exports);
29
29
  __exportStar(require("./match"), exports);
30
30
  __exportStar(require("./match-rating"), exports);
31
- __exportStar(require("./match-result"), exports);
32
31
  __exportStar(require("./match-set"), exports);
33
32
  __exportStar(require("./performance-stats"), exports);
34
33
  __exportStar(require("./player"), exports);
@@ -37,3 +36,4 @@ __exportStar(require("./rally"), exports);
37
36
  __exportStar(require("./team"), exports);
38
37
  __exportStar(require("./user"), exports);
39
38
  __exportStar(require("./tactics"), exports);
39
+ __exportStar(require("./views"), exports);
@@ -45,7 +45,12 @@ class TeamModel extends sequelize_1.Model {
45
45
  tableName: 'Team',
46
46
  schema: 'public',
47
47
  timestamps: false,
48
- defaultScope: { include: [{ model: _1.CountryModel, as: 'country' }] },
48
+ defaultScope: {
49
+ include: [
50
+ { model: _1.CountryModel, as: 'country' },
51
+ { model: _1.TacticsModel, as: 'tactics' }
52
+ ]
53
+ },
49
54
  indexes: [{
50
55
  name: 'Team_pk',
51
56
  unique: true,
@@ -0,0 +1,71 @@
1
+ import * as Sequelize from 'sequelize';
2
+ import { Model } from 'sequelize';
3
+ import { PlayerId, PlayerModel } from '..';
4
+ export interface BoxScoreTotalsAttributes {
5
+ player_id: string;
6
+ attack_attempts: number;
7
+ attack_kills: number;
8
+ attack_errors: number;
9
+ serve_attempts: number;
10
+ serve_aces: number;
11
+ serve_errors: number;
12
+ reception_attempts: number;
13
+ reception_perfect: number;
14
+ reception_positive: number;
15
+ reception_overpasses: number;
16
+ reception_errors: number;
17
+ block_solo: number;
18
+ block_assists: number;
19
+ block_errors: number;
20
+ block_touches: number;
21
+ setting_assists: number;
22
+ setting_errors: number;
23
+ setting_pass: number;
24
+ defense_digs: number;
25
+ defense_errors: number;
26
+ misc_points_played: number;
27
+ misc_points_won_on_court: number;
28
+ misc_serve_turns: number;
29
+ misc_sideout_opportunities: number;
30
+ misc_successful_sideouts: number;
31
+ misc_sets_played: number;
32
+ misc_matches_played: number;
33
+ }
34
+ export type BoxScoreTotalsPk = 'player_id';
35
+ export type BoxScoreTotalsId = BoxScoreTotalsModel[BoxScoreTotalsPk];
36
+ export type BoxScoreTotalsCreationAttributes = BoxScoreTotalsAttributes;
37
+ export declare class BoxScoreTotalsModel extends Model<BoxScoreTotalsAttributes, BoxScoreTotalsCreationAttributes> implements BoxScoreTotalsAttributes {
38
+ player_id: string;
39
+ attack_attempts: number;
40
+ attack_kills: number;
41
+ attack_errors: number;
42
+ serve_attempts: number;
43
+ serve_aces: number;
44
+ serve_errors: number;
45
+ reception_attempts: number;
46
+ reception_perfect: number;
47
+ reception_positive: number;
48
+ reception_overpasses: number;
49
+ reception_errors: number;
50
+ block_solo: number;
51
+ block_assists: number;
52
+ block_errors: number;
53
+ block_touches: number;
54
+ setting_assists: number;
55
+ setting_errors: number;
56
+ setting_pass: number;
57
+ defense_digs: number;
58
+ defense_errors: number;
59
+ misc_points_played: number;
60
+ misc_points_won_on_court: number;
61
+ misc_serve_turns: number;
62
+ misc_sideout_opportunities: number;
63
+ misc_successful_sideouts: number;
64
+ misc_sets_played: number;
65
+ misc_matches_played: number;
66
+ Player: PlayerModel;
67
+ getPlayer: Sequelize.BelongsToGetAssociationMixin<PlayerModel>;
68
+ setPlayer: Sequelize.BelongsToSetAssociationMixin<PlayerModel, PlayerId>;
69
+ createPlayer: Sequelize.BelongsToCreateAssociationMixin<PlayerModel>;
70
+ static initModel(sequelize: Sequelize.Sequelize): typeof BoxScoreTotalsModel;
71
+ }
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BoxScoreTotalsModel = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ class BoxScoreTotalsModel extends sequelize_1.Model {
6
+ static initModel(sequelize) {
7
+ return BoxScoreTotalsModel.init({
8
+ player_id: {
9
+ type: sequelize_1.DataTypes.UUID,
10
+ allowNull: false,
11
+ primaryKey: true,
12
+ references: {
13
+ model: 'Player',
14
+ key: 'player_id'
15
+ }
16
+ },
17
+ attack_attempts: {
18
+ type: sequelize_1.DataTypes.INTEGER,
19
+ allowNull: false
20
+ },
21
+ attack_kills: {
22
+ type: sequelize_1.DataTypes.INTEGER,
23
+ allowNull: false
24
+ },
25
+ attack_errors: {
26
+ type: sequelize_1.DataTypes.INTEGER,
27
+ allowNull: false
28
+ },
29
+ serve_attempts: {
30
+ type: sequelize_1.DataTypes.INTEGER,
31
+ allowNull: false
32
+ },
33
+ serve_aces: {
34
+ type: sequelize_1.DataTypes.INTEGER,
35
+ allowNull: false
36
+ },
37
+ serve_errors: {
38
+ type: sequelize_1.DataTypes.INTEGER,
39
+ allowNull: false
40
+ },
41
+ reception_attempts: {
42
+ type: sequelize_1.DataTypes.INTEGER,
43
+ allowNull: false
44
+ },
45
+ reception_perfect: {
46
+ type: sequelize_1.DataTypes.INTEGER,
47
+ allowNull: false
48
+ },
49
+ reception_positive: {
50
+ type: sequelize_1.DataTypes.INTEGER,
51
+ allowNull: false
52
+ },
53
+ reception_overpasses: {
54
+ type: sequelize_1.DataTypes.INTEGER,
55
+ allowNull: false
56
+ },
57
+ reception_errors: {
58
+ type: sequelize_1.DataTypes.INTEGER,
59
+ allowNull: false
60
+ },
61
+ block_solo: {
62
+ type: sequelize_1.DataTypes.INTEGER,
63
+ allowNull: false
64
+ },
65
+ block_assists: {
66
+ type: sequelize_1.DataTypes.INTEGER,
67
+ allowNull: false
68
+ },
69
+ block_errors: {
70
+ type: sequelize_1.DataTypes.INTEGER,
71
+ allowNull: false
72
+ },
73
+ block_touches: {
74
+ type: sequelize_1.DataTypes.INTEGER,
75
+ allowNull: false
76
+ },
77
+ setting_assists: {
78
+ type: sequelize_1.DataTypes.INTEGER,
79
+ allowNull: false
80
+ },
81
+ setting_errors: {
82
+ type: sequelize_1.DataTypes.INTEGER,
83
+ allowNull: false
84
+ },
85
+ setting_pass: {
86
+ type: sequelize_1.DataTypes.INTEGER,
87
+ allowNull: false
88
+ },
89
+ defense_digs: {
90
+ type: sequelize_1.DataTypes.INTEGER,
91
+ allowNull: false
92
+ },
93
+ defense_errors: {
94
+ type: sequelize_1.DataTypes.INTEGER,
95
+ allowNull: false
96
+ },
97
+ misc_points_played: {
98
+ type: sequelize_1.DataTypes.INTEGER,
99
+ allowNull: false
100
+ },
101
+ misc_points_won_on_court: {
102
+ type: sequelize_1.DataTypes.INTEGER,
103
+ allowNull: false
104
+ },
105
+ misc_serve_turns: {
106
+ type: sequelize_1.DataTypes.INTEGER,
107
+ allowNull: false
108
+ },
109
+ misc_sideout_opportunities: {
110
+ type: sequelize_1.DataTypes.INTEGER,
111
+ allowNull: false
112
+ },
113
+ misc_successful_sideouts: {
114
+ type: sequelize_1.DataTypes.INTEGER,
115
+ allowNull: false
116
+ },
117
+ misc_sets_played: {
118
+ type: sequelize_1.DataTypes.INTEGER,
119
+ allowNull: false
120
+ },
121
+ misc_matches_played: {
122
+ type: sequelize_1.DataTypes.INTEGER,
123
+ allowNull: false
124
+ }
125
+ }, {
126
+ sequelize,
127
+ tableName: 'BoxScoreTotals',
128
+ schema: 'public',
129
+ timestamps: false,
130
+ indexes: [{
131
+ name: 'BoxScoreTotals_pk',
132
+ unique: true,
133
+ fields: [{ name: 'player_id' }]
134
+ }]
135
+ });
136
+ }
137
+ }
138
+ exports.BoxScoreTotalsModel = BoxScoreTotalsModel;
@@ -0,0 +1,51 @@
1
+ import * as Sequelize from 'sequelize';
2
+ import { Model } from 'sequelize';
3
+ import { CompetitionId, CompetitionModel, TeamId, TeamModel } from '..';
4
+ export interface HistoricStandingsAttributes {
5
+ competition_id: string;
6
+ team_id: string;
7
+ won30: number;
8
+ won31: number;
9
+ won32: number;
10
+ lost03: number;
11
+ lost13: number;
12
+ lost23: number;
13
+ points_won: number;
14
+ points_lost: number;
15
+ points: number;
16
+ sets_won: number;
17
+ sets_lost: number;
18
+ matches_won: number;
19
+ matches_lost: number;
20
+ total_matches: number;
21
+ }
22
+ export type HistoricStandingsPk = 'competition_id' | 'team_id';
23
+ export type HistoricStandingsId = HistoricStandingsModel[HistoricStandingsPk];
24
+ export type HistoricStandingsCreationAttributes = HistoricStandingsAttributes;
25
+ export declare class HistoricStandingsModel extends Model<HistoricStandingsAttributes, HistoricStandingsCreationAttributes> implements HistoricStandingsAttributes {
26
+ competition_id: string;
27
+ team_id: string;
28
+ won30: number;
29
+ won31: number;
30
+ won32: number;
31
+ lost03: number;
32
+ lost13: number;
33
+ lost23: number;
34
+ points_won: number;
35
+ points_lost: number;
36
+ points: number;
37
+ sets_won: number;
38
+ sets_lost: number;
39
+ matches_won: number;
40
+ matches_lost: number;
41
+ total_matches: number;
42
+ Competition: CompetitionModel;
43
+ getCompetition: Sequelize.BelongsToGetAssociationMixin<CompetitionModel>;
44
+ setCompetition: Sequelize.BelongsToSetAssociationMixin<CompetitionModel, CompetitionId>;
45
+ createCompetition: Sequelize.BelongsToCreateAssociationMixin<CompetitionModel>;
46
+ Team: TeamModel;
47
+ getTeam: Sequelize.BelongsToGetAssociationMixin<TeamModel>;
48
+ setTeam: Sequelize.BelongsToSetAssociationMixin<TeamModel, TeamId>;
49
+ createTeam: Sequelize.BelongsToCreateAssociationMixin<TeamModel>;
50
+ static initModel(sequelize: Sequelize.Sequelize): typeof HistoricStandingsModel;
51
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HistoricStandingsModel = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ class HistoricStandingsModel extends sequelize_1.Model {
6
+ static initModel(sequelize) {
7
+ return HistoricStandingsModel.init({
8
+ competition_id: {
9
+ type: sequelize_1.DataTypes.UUID,
10
+ allowNull: false,
11
+ primaryKey: true,
12
+ references: {
13
+ model: 'Competition',
14
+ key: 'competition_id'
15
+ }
16
+ },
17
+ team_id: {
18
+ type: sequelize_1.DataTypes.UUID,
19
+ allowNull: false,
20
+ primaryKey: true,
21
+ references: {
22
+ model: 'Team',
23
+ key: 'team_id'
24
+ }
25
+ },
26
+ won30: { type: sequelize_1.DataTypes.INTEGER, allowNull: false },
27
+ won31: { type: sequelize_1.DataTypes.INTEGER, allowNull: false },
28
+ won32: { type: sequelize_1.DataTypes.INTEGER, allowNull: false },
29
+ lost03: { type: sequelize_1.DataTypes.INTEGER, allowNull: false },
30
+ lost13: { type: sequelize_1.DataTypes.INTEGER, allowNull: false },
31
+ lost23: { type: sequelize_1.DataTypes.INTEGER, allowNull: false },
32
+ points_won: { type: sequelize_1.DataTypes.INTEGER, allowNull: false },
33
+ points_lost: { type: sequelize_1.DataTypes.INTEGER, allowNull: false },
34
+ points: { type: sequelize_1.DataTypes.INTEGER, allowNull: false },
35
+ sets_won: { type: sequelize_1.DataTypes.INTEGER, allowNull: false },
36
+ sets_lost: { type: sequelize_1.DataTypes.INTEGER, allowNull: false },
37
+ matches_won: { type: sequelize_1.DataTypes.INTEGER, allowNull: false },
38
+ matches_lost: { type: sequelize_1.DataTypes.INTEGER, allowNull: false },
39
+ total_matches: { type: sequelize_1.DataTypes.INTEGER, allowNull: false }
40
+ }, {
41
+ sequelize,
42
+ tableName: 'HistoricStandings',
43
+ schema: 'public',
44
+ timestamps: false,
45
+ indexes: [{
46
+ name: 'HistoricStandings_pk',
47
+ unique: true,
48
+ fields: [
49
+ { name: 'competition_id' },
50
+ { name: 'team_id' }
51
+ ]
52
+ }]
53
+ });
54
+ }
55
+ }
56
+ exports.HistoricStandingsModel = HistoricStandingsModel;
@@ -0,0 +1,3 @@
1
+ export * from './box-score-totals';
2
+ export * from './match-result';
3
+ export * from './historic-standings';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./box-score-totals"), exports);
18
+ __exportStar(require("./match-result"), exports);
19
+ __exportStar(require("./historic-standings"), exports);
@@ -1,6 +1,6 @@
1
1
  import * as Sequelize from 'sequelize';
2
2
  import { Model } from 'sequelize';
3
- import { MatchId, MatchModel, TeamId, TeamModel } from '.';
3
+ import { MatchId, MatchModel, TeamId, TeamModel } from '..';
4
4
  export interface MatchResultAttributes {
5
5
  match_id: string;
6
6
  home_score: number;
@@ -19,9 +19,9 @@ export declare class MatchResultModel extends Model<MatchResultAttributes, Match
19
19
  getMatch: Sequelize.BelongsToGetAssociationMixin<MatchModel>;
20
20
  setMatch: Sequelize.BelongsToSetAssociationMixin<MatchModel, MatchId>;
21
21
  createMatch: Sequelize.BelongsToCreateAssociationMixin<MatchModel>;
22
- WinnerTeam: TeamModel;
23
- getWinnerTeam: Sequelize.BelongsToGetAssociationMixin<TeamModel>;
24
- setWinnerTeam: Sequelize.BelongsToSetAssociationMixin<TeamModel, TeamId>;
25
- createWinnerTeam: Sequelize.BelongsToCreateAssociationMixin<TeamModel>;
22
+ Winner: TeamModel;
23
+ getWinner: Sequelize.BelongsToGetAssociationMixin<TeamModel>;
24
+ setWinner: Sequelize.BelongsToSetAssociationMixin<TeamModel, TeamId>;
25
+ createWinner: Sequelize.BelongsToCreateAssociationMixin<TeamModel>;
26
26
  static initModel(sequelize: Sequelize.Sequelize): typeof MatchResultModel;
27
27
  }
@@ -24,7 +24,7 @@ class MatchResultModel extends sequelize_1.Model {
24
24
  }
25
25
  }, {
26
26
  sequelize,
27
- tableName: 'MatchResultView',
27
+ tableName: 'MatchResult',
28
28
  schema: 'public',
29
29
  timestamps: false,
30
30
  indexes: [{
@@ -26,7 +26,7 @@ function transformToObject(model) {
26
26
  status: model.status,
27
27
  homeScore: model.MatchResult?.home_score,
28
28
  awayScore: model.MatchResult?.away_score,
29
- winner: model.MatchResult?.WinnerTeam != null ? (0, team_1.transformToTeam)(model.MatchResult.WinnerTeam) : undefined
29
+ winner: model.MatchResult?.Winner != null ? (0, team_1.transformToTeam)(model.MatchResult.Winner) : undefined
30
30
  });
31
31
  }
32
32
  exports.transformToMatch = transformToObject;
@@ -23,6 +23,5 @@ export declare class Season {
23
23
  champion?: Team;
24
24
  constructor({ id, iteration, teams, matches, champion, status, divisionId }: SeasonOpts);
25
25
  calculateStandings(): Standing[];
26
- updateStandings(): void;
27
26
  }
28
27
  export {};
@@ -20,14 +20,5 @@ class Season {
20
20
  return standing;
21
21
  }).sort(standing_1.Standing.sortFn);
22
22
  }
23
- updateStandings() {
24
- if (this.matches == null || this.matches.length < 1)
25
- throw new Error('NO_MATCHES');
26
- this.standings.length = 0;
27
- this.standings.push(...this.calculateStandings());
28
- if (this.matches.every((match) => match.isOver())) {
29
- this.champion = this.standings[0].team;
30
- }
31
- }
32
23
  }
33
24
  exports.Season = Season;
@@ -43,8 +43,6 @@ class Standing {
43
43
  .filter(match => match.isOver());
44
44
  let teamSide;
45
45
  let otherSide;
46
- let teamScore;
47
- let otherScore;
48
46
  for (const match of matches) {
49
47
  if (this.team.id === match.homeTeam.id) {
50
48
  teamSide = match_1.MatchTeam.HOME;
@@ -60,11 +58,9 @@ class Standing {
60
58
  else {
61
59
  this[`lost${match.getTeamSets(teamSide)}3`]++;
62
60
  }
63
- teamScore = `${teamSide === match_1.MatchTeam.HOME ? 'home' : 'away'}Score`;
64
- otherScore = `${otherSide === match_1.MatchTeam.HOME ? 'home' : 'away'}Score`;
65
61
  for (const set of match.sets) {
66
- this.pointsWon += set[teamScore];
67
- this.pointsLost += set[otherScore];
62
+ this.pointsWon += set[teamSide === match_1.MatchTeam.HOME ? 'homeScore' : 'awayScore'];
63
+ this.pointsLost += set[otherSide === match_1.MatchTeam.HOME ? 'homeScore' : 'awayScore'];
68
64
  }
69
65
  }
70
66
  this.points = (this.won30 + this.won31) * 3 + this.won32 * 2 + this.lost23;
@@ -13,14 +13,8 @@ interface MatchParams {
13
13
  awayScore?: number;
14
14
  winner?: Team;
15
15
  }
16
- export declare enum MatchScore {
17
- '3-0' = "3-0",
18
- '3-1' = "3-1",
19
- '3-2' = "3-2",
20
- '2-3' = "2-3",
21
- '1-3' = "1-3",
22
- '0-3' = "0-3"
23
- }
16
+ export type MatchScore = '3-0' | '3-1' | '3-2' | '2-3' | '1-3' | '0-3';
17
+ export type SetScore = 0 | 1 | 2 | 3;
24
18
  export declare class Match {
25
19
  readonly id: string;
26
20
  readonly homeTeam: Team;
@@ -33,7 +27,7 @@ export declare class Match {
33
27
  status: StatusEnum;
34
28
  constructor({ id, homeTeam, awayTeam, scheduledDate, sets, status, homeScore, awayScore, winner }: MatchParams);
35
29
  addSet(set: MatchSet): void;
36
- getTeamSets(team: MatchTeam): number;
30
+ getTeamSets(team: MatchTeam): SetScore;
37
31
  getScore(): MatchScore;
38
32
  isOver(): boolean;
39
33
  getWinner(): Team;
@@ -1,18 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Match = exports.MatchScore = void 0;
3
+ exports.Match = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  const match_team_1 = require("./match-team");
6
6
  const data_1 = require("../../data");
7
- var MatchScore;
8
- (function (MatchScore) {
9
- MatchScore["3-0"] = "3-0";
10
- MatchScore["3-1"] = "3-1";
11
- MatchScore["3-2"] = "3-2";
12
- MatchScore["2-3"] = "2-3";
13
- MatchScore["1-3"] = "1-3";
14
- MatchScore["0-3"] = "0-3";
15
- })(MatchScore = exports.MatchScore || (exports.MatchScore = {}));
16
7
  class Match {
17
8
  constructor({ id, homeTeam, awayTeam, scheduledDate, sets, status, homeScore, awayScore, winner }) {
18
9
  (0, utils_1.validateUUID)(id);
@@ -32,7 +23,10 @@ class Match {
32
23
  this.sets.push(set);
33
24
  }
34
25
  getTeamSets(team) {
35
- return this.sets.reduce((sets, set) => sets + (!set.isOver() ? 0 : set.getWinner() === team ? 1 : 0), 0);
26
+ const sets = this.sets.reduce((sets, set) => sets + (!set.isOver() ? 0 : set.getWinner() === team ? 1 : 0), 0);
27
+ if (sets > 3 || sets < 0)
28
+ throw new Error(`INCORRECT_SET_VALUE: ${sets}`);
29
+ return sets;
36
30
  }
37
31
  getScore() {
38
32
  return `${this.getTeamSets(match_team_1.MatchTeam.HOME)}-${this.getTeamSets(match_team_1.MatchTeam.AWAY)}`;
@@ -1,12 +1,10 @@
1
1
  import { CourtPosition } from './court-position';
2
2
  import { RallyEvent } from '../event';
3
- import { Team } from '../team';
4
3
  interface RallyParams {
5
4
  readonly id: string;
6
5
  readonly order: number;
7
6
  readonly servingTeamId: string;
8
7
  readonly events: RallyEvent[];
9
- winner?: Team;
10
8
  }
11
9
  export interface PlayerPosition {
12
10
  position: CourtPosition;
@@ -17,8 +15,7 @@ export declare class Rally {
17
15
  readonly servingTeamId: string;
18
16
  readonly events: RallyEvent[];
19
17
  readonly order: number;
20
- winner?: Team;
21
- constructor({ id, order, servingTeamId, events, winner }: RallyParams);
18
+ constructor({ id, order, servingTeamId, events }: RallyParams);
22
19
  addEvent(event: RallyEvent): void;
23
20
  }
24
21
  export {};
@@ -3,13 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Rally = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  class Rally {
6
- constructor({ id, order, servingTeamId, events, winner }) {
6
+ constructor({ id, order, servingTeamId, events }) {
7
7
  (0, utils_1.validateUUID)(id);
8
8
  this.id = id;
9
9
  this.order = order;
10
10
  this.servingTeamId = servingTeamId;
11
11
  this.events = events;
12
- this.winner = winner;
13
12
  }
14
13
  addEvent(event) {
15
14
  this.events.push(event);
@@ -1,4 +1,4 @@
1
- import { BoxScoreModel, CompetitionChampionModel, CompetitionMatchModel, CompetitionModel, CompetitionTeamsModel, CountryModel, DivisionModel, DivisionSeasonModel, DraftModel, DraftPickModel, IterationModel, LeagueModel, MatchModel, MatchRatingModel, MatchResultModel, MatchSetModel, PerformanceStatsModel, PlayerModel, PlayerTeamModel, RallyModel, TacticsModel, TeamModel, UserModel } from './models';
1
+ import { BoxScoreModel, BoxScoreTotalsModel, CompetitionChampionModel, CompetitionMatchModel, CompetitionModel, CompetitionTeamsModel, CountryModel, DivisionModel, DivisionSeasonModel, HistoricStandingsModel, DraftModel, DraftPickModel, IterationModel, LeagueModel, MatchModel, MatchRatingModel, MatchResultModel, MatchSetModel, PerformanceStatsModel, PlayerModel, PlayerTeamModel, RallyModel, TacticsModel, TeamModel, UserModel } from './models';
2
2
  export function initModels(sequelize) {
3
3
  const Tactics = TacticsModel.initModel(sequelize);
4
4
  const Country = CountryModel.initModel(sequelize);
@@ -12,11 +12,13 @@ export function initModels(sequelize) {
12
12
  const League = LeagueModel.initModel(sequelize);
13
13
  const Division = DivisionModel.initModel(sequelize);
14
14
  const DivisionSeason = DivisionSeasonModel.initModel(sequelize);
15
+ const HistoricStandings = HistoricStandingsModel.initModel(sequelize);
15
16
  const Match = MatchModel.initModel(sequelize);
16
17
  const MatchRating = MatchRatingModel.initModel(sequelize);
17
18
  const MatchResult = MatchResultModel.initModel(sequelize);
18
19
  const MatchSet = MatchSetModel.initModel(sequelize);
19
20
  const BoxScore = BoxScoreModel.initModel(sequelize);
21
+ const BoxScoreTotals = BoxScoreTotalsModel.initModel(sequelize);
20
22
  const PerformanceStats = PerformanceStatsModel.initModel(sequelize);
21
23
  const Player = PlayerModel.initModel(sequelize);
22
24
  const PlayerTeam = PlayerTeamModel.initModel(sequelize);
@@ -56,6 +58,8 @@ export function initModels(sequelize) {
56
58
  Division.hasMany(Team, { as: 'Teams', foreignKey: 'division_id' });
57
59
  DivisionSeason.belongsTo(Competition, { as: 'competition', foreignKey: 'competition_id' });
58
60
  DivisionSeason.belongsTo(Division, { as: 'division', foreignKey: 'division_id' });
61
+ HistoricStandings.belongsTo(Competition, { as: 'Competition', foreignKey: 'competition_id' });
62
+ HistoricStandings.belongsTo(Team, { as: 'Team', foreignKey: 'team_id' });
59
63
  Team.belongsTo(Division, { as: 'Division', foreignKey: 'division_id' });
60
64
  Match.belongsTo(Team, { as: 'AwayTeam', foreignKey: 'away_team' });
61
65
  Match.belongsTo(Team, { as: 'HomeTeam', foreignKey: 'home_team' });
@@ -70,7 +74,7 @@ export function initModels(sequelize) {
70
74
  Match.hasOne(CompetitionMatch, { as: 'CompetitionMatch', foreignKey: 'match_id' });
71
75
  Match.hasOne(MatchResult, { as: 'MatchResult', foreignKey: 'match_id' });
72
76
  MatchResult.belongsTo(Match, { as: 'Match', foreignKey: 'match_id' });
73
- MatchResult.belongsTo(Team, { as: 'WinnerTeam', foreignKey: 'winner_team_id' });
77
+ MatchResult.belongsTo(Team, { as: 'Winner', foreignKey: 'winner_team_id' });
74
78
  MatchRating.belongsTo(Match, { as: 'match', foreignKey: 'match_id' });
75
79
  MatchRating.belongsTo(Team, { as: 'team', foreignKey: 'team_id' });
76
80
  MatchSet.belongsTo(Match, { as: 'match', foreignKey: 'match_id' });
@@ -84,6 +88,7 @@ export function initModels(sequelize) {
84
88
  MatchSet.hasMany(Rally, { as: 'Rallies', foreignKey: 'match_set_id' });
85
89
  BoxScore.belongsTo(MatchSet, { as: 'MatchSet', foreignKey: 'match_set_id' });
86
90
  BoxScore.belongsTo(Player, { as: 'Player', foreignKey: 'player_id' });
91
+ BoxScoreTotals.belongsTo(Player, { as: 'Player', foreignKey: 'player_id' });
87
92
  PerformanceStats.belongsTo(Player, { as: 'player', foreignKey: 'player_id' });
88
93
  Player.belongsTo(Country, { as: 'country', foreignKey: 'country_id' });
89
94
  Player.belongsToMany(MatchSet, {
@@ -147,11 +152,13 @@ export function initModels(sequelize) {
147
152
  Iteration,
148
153
  League,
149
154
  DivisionSeason,
155
+ HistoricStandings,
150
156
  Match,
151
157
  MatchRating,
152
158
  MatchResult,
153
159
  MatchSet,
154
160
  BoxScore,
161
+ BoxScoreTotals,
155
162
  PerformanceStats,
156
163
  Player,
157
164
  PlayerTeam,
@@ -12,7 +12,6 @@ export * from './division';
12
12
  export * from './division-season';
13
13
  export * from './match';
14
14
  export * from './match-rating';
15
- export * from './match-result';
16
15
  export * from './match-set';
17
16
  export * from './performance-stats';
18
17
  export * from './player';
@@ -21,3 +20,4 @@ export * from './rally';
21
20
  export * from './team';
22
21
  export * from './user';
23
22
  export * from './tactics';
23
+ export * from './views';
@@ -12,7 +12,6 @@ export * from './division';
12
12
  export * from './division-season';
13
13
  export * from './match';
14
14
  export * from './match-rating';
15
- export * from './match-result';
16
15
  export * from './match-set';
17
16
  export * from './performance-stats';
18
17
  export * from './player';
@@ -21,3 +20,4 @@ export * from './rally';
21
20
  export * from './team';
22
21
  export * from './user';
23
22
  export * from './tactics';
23
+ export * from './views';
@@ -1,5 +1,5 @@
1
1
  import { DataTypes, Model } from 'sequelize';
2
- import { CountryModel } from '.';
2
+ import { CountryModel, TacticsModel } from '.';
3
3
  export class TeamModel extends Model {
4
4
  static initModel(sequelize) {
5
5
  return TeamModel.init({
@@ -42,7 +42,12 @@ export class TeamModel extends Model {
42
42
  tableName: 'Team',
43
43
  schema: 'public',
44
44
  timestamps: false,
45
- defaultScope: { include: [{ model: CountryModel, as: 'country' }] },
45
+ defaultScope: {
46
+ include: [
47
+ { model: CountryModel, as: 'country' },
48
+ { model: TacticsModel, as: 'tactics' }
49
+ ]
50
+ },
46
51
  indexes: [{
47
52
  name: 'Team_pk',
48
53
  unique: true,
@@ -0,0 +1,71 @@
1
+ import * as Sequelize from 'sequelize';
2
+ import { Model } from 'sequelize';
3
+ import { PlayerId, PlayerModel } from '..';
4
+ export interface BoxScoreTotalsAttributes {
5
+ player_id: string;
6
+ attack_attempts: number;
7
+ attack_kills: number;
8
+ attack_errors: number;
9
+ serve_attempts: number;
10
+ serve_aces: number;
11
+ serve_errors: number;
12
+ reception_attempts: number;
13
+ reception_perfect: number;
14
+ reception_positive: number;
15
+ reception_overpasses: number;
16
+ reception_errors: number;
17
+ block_solo: number;
18
+ block_assists: number;
19
+ block_errors: number;
20
+ block_touches: number;
21
+ setting_assists: number;
22
+ setting_errors: number;
23
+ setting_pass: number;
24
+ defense_digs: number;
25
+ defense_errors: number;
26
+ misc_points_played: number;
27
+ misc_points_won_on_court: number;
28
+ misc_serve_turns: number;
29
+ misc_sideout_opportunities: number;
30
+ misc_successful_sideouts: number;
31
+ misc_sets_played: number;
32
+ misc_matches_played: number;
33
+ }
34
+ export type BoxScoreTotalsPk = 'player_id';
35
+ export type BoxScoreTotalsId = BoxScoreTotalsModel[BoxScoreTotalsPk];
36
+ export type BoxScoreTotalsCreationAttributes = BoxScoreTotalsAttributes;
37
+ export declare class BoxScoreTotalsModel extends Model<BoxScoreTotalsAttributes, BoxScoreTotalsCreationAttributes> implements BoxScoreTotalsAttributes {
38
+ player_id: string;
39
+ attack_attempts: number;
40
+ attack_kills: number;
41
+ attack_errors: number;
42
+ serve_attempts: number;
43
+ serve_aces: number;
44
+ serve_errors: number;
45
+ reception_attempts: number;
46
+ reception_perfect: number;
47
+ reception_positive: number;
48
+ reception_overpasses: number;
49
+ reception_errors: number;
50
+ block_solo: number;
51
+ block_assists: number;
52
+ block_errors: number;
53
+ block_touches: number;
54
+ setting_assists: number;
55
+ setting_errors: number;
56
+ setting_pass: number;
57
+ defense_digs: number;
58
+ defense_errors: number;
59
+ misc_points_played: number;
60
+ misc_points_won_on_court: number;
61
+ misc_serve_turns: number;
62
+ misc_sideout_opportunities: number;
63
+ misc_successful_sideouts: number;
64
+ misc_sets_played: number;
65
+ misc_matches_played: number;
66
+ Player: PlayerModel;
67
+ getPlayer: Sequelize.BelongsToGetAssociationMixin<PlayerModel>;
68
+ setPlayer: Sequelize.BelongsToSetAssociationMixin<PlayerModel, PlayerId>;
69
+ createPlayer: Sequelize.BelongsToCreateAssociationMixin<PlayerModel>;
70
+ static initModel(sequelize: Sequelize.Sequelize): typeof BoxScoreTotalsModel;
71
+ }
@@ -0,0 +1,134 @@
1
+ import { DataTypes, Model } from 'sequelize';
2
+ export class BoxScoreTotalsModel extends Model {
3
+ static initModel(sequelize) {
4
+ return BoxScoreTotalsModel.init({
5
+ player_id: {
6
+ type: DataTypes.UUID,
7
+ allowNull: false,
8
+ primaryKey: true,
9
+ references: {
10
+ model: 'Player',
11
+ key: 'player_id'
12
+ }
13
+ },
14
+ attack_attempts: {
15
+ type: DataTypes.INTEGER,
16
+ allowNull: false
17
+ },
18
+ attack_kills: {
19
+ type: DataTypes.INTEGER,
20
+ allowNull: false
21
+ },
22
+ attack_errors: {
23
+ type: DataTypes.INTEGER,
24
+ allowNull: false
25
+ },
26
+ serve_attempts: {
27
+ type: DataTypes.INTEGER,
28
+ allowNull: false
29
+ },
30
+ serve_aces: {
31
+ type: DataTypes.INTEGER,
32
+ allowNull: false
33
+ },
34
+ serve_errors: {
35
+ type: DataTypes.INTEGER,
36
+ allowNull: false
37
+ },
38
+ reception_attempts: {
39
+ type: DataTypes.INTEGER,
40
+ allowNull: false
41
+ },
42
+ reception_perfect: {
43
+ type: DataTypes.INTEGER,
44
+ allowNull: false
45
+ },
46
+ reception_positive: {
47
+ type: DataTypes.INTEGER,
48
+ allowNull: false
49
+ },
50
+ reception_overpasses: {
51
+ type: DataTypes.INTEGER,
52
+ allowNull: false
53
+ },
54
+ reception_errors: {
55
+ type: DataTypes.INTEGER,
56
+ allowNull: false
57
+ },
58
+ block_solo: {
59
+ type: DataTypes.INTEGER,
60
+ allowNull: false
61
+ },
62
+ block_assists: {
63
+ type: DataTypes.INTEGER,
64
+ allowNull: false
65
+ },
66
+ block_errors: {
67
+ type: DataTypes.INTEGER,
68
+ allowNull: false
69
+ },
70
+ block_touches: {
71
+ type: DataTypes.INTEGER,
72
+ allowNull: false
73
+ },
74
+ setting_assists: {
75
+ type: DataTypes.INTEGER,
76
+ allowNull: false
77
+ },
78
+ setting_errors: {
79
+ type: DataTypes.INTEGER,
80
+ allowNull: false
81
+ },
82
+ setting_pass: {
83
+ type: DataTypes.INTEGER,
84
+ allowNull: false
85
+ },
86
+ defense_digs: {
87
+ type: DataTypes.INTEGER,
88
+ allowNull: false
89
+ },
90
+ defense_errors: {
91
+ type: DataTypes.INTEGER,
92
+ allowNull: false
93
+ },
94
+ misc_points_played: {
95
+ type: DataTypes.INTEGER,
96
+ allowNull: false
97
+ },
98
+ misc_points_won_on_court: {
99
+ type: DataTypes.INTEGER,
100
+ allowNull: false
101
+ },
102
+ misc_serve_turns: {
103
+ type: DataTypes.INTEGER,
104
+ allowNull: false
105
+ },
106
+ misc_sideout_opportunities: {
107
+ type: DataTypes.INTEGER,
108
+ allowNull: false
109
+ },
110
+ misc_successful_sideouts: {
111
+ type: DataTypes.INTEGER,
112
+ allowNull: false
113
+ },
114
+ misc_sets_played: {
115
+ type: DataTypes.INTEGER,
116
+ allowNull: false
117
+ },
118
+ misc_matches_played: {
119
+ type: DataTypes.INTEGER,
120
+ allowNull: false
121
+ }
122
+ }, {
123
+ sequelize,
124
+ tableName: 'BoxScoreTotals',
125
+ schema: 'public',
126
+ timestamps: false,
127
+ indexes: [{
128
+ name: 'BoxScoreTotals_pk',
129
+ unique: true,
130
+ fields: [{ name: 'player_id' }]
131
+ }]
132
+ });
133
+ }
134
+ }
@@ -0,0 +1,51 @@
1
+ import * as Sequelize from 'sequelize';
2
+ import { Model } from 'sequelize';
3
+ import { CompetitionId, CompetitionModel, TeamId, TeamModel } from '..';
4
+ export interface HistoricStandingsAttributes {
5
+ competition_id: string;
6
+ team_id: string;
7
+ won30: number;
8
+ won31: number;
9
+ won32: number;
10
+ lost03: number;
11
+ lost13: number;
12
+ lost23: number;
13
+ points_won: number;
14
+ points_lost: number;
15
+ points: number;
16
+ sets_won: number;
17
+ sets_lost: number;
18
+ matches_won: number;
19
+ matches_lost: number;
20
+ total_matches: number;
21
+ }
22
+ export type HistoricStandingsPk = 'competition_id' | 'team_id';
23
+ export type HistoricStandingsId = HistoricStandingsModel[HistoricStandingsPk];
24
+ export type HistoricStandingsCreationAttributes = HistoricStandingsAttributes;
25
+ export declare class HistoricStandingsModel extends Model<HistoricStandingsAttributes, HistoricStandingsCreationAttributes> implements HistoricStandingsAttributes {
26
+ competition_id: string;
27
+ team_id: string;
28
+ won30: number;
29
+ won31: number;
30
+ won32: number;
31
+ lost03: number;
32
+ lost13: number;
33
+ lost23: number;
34
+ points_won: number;
35
+ points_lost: number;
36
+ points: number;
37
+ sets_won: number;
38
+ sets_lost: number;
39
+ matches_won: number;
40
+ matches_lost: number;
41
+ total_matches: number;
42
+ Competition: CompetitionModel;
43
+ getCompetition: Sequelize.BelongsToGetAssociationMixin<CompetitionModel>;
44
+ setCompetition: Sequelize.BelongsToSetAssociationMixin<CompetitionModel, CompetitionId>;
45
+ createCompetition: Sequelize.BelongsToCreateAssociationMixin<CompetitionModel>;
46
+ Team: TeamModel;
47
+ getTeam: Sequelize.BelongsToGetAssociationMixin<TeamModel>;
48
+ setTeam: Sequelize.BelongsToSetAssociationMixin<TeamModel, TeamId>;
49
+ createTeam: Sequelize.BelongsToCreateAssociationMixin<TeamModel>;
50
+ static initModel(sequelize: Sequelize.Sequelize): typeof HistoricStandingsModel;
51
+ }
@@ -0,0 +1,52 @@
1
+ import { DataTypes, Model } from 'sequelize';
2
+ export class HistoricStandingsModel extends Model {
3
+ static initModel(sequelize) {
4
+ return HistoricStandingsModel.init({
5
+ competition_id: {
6
+ type: DataTypes.UUID,
7
+ allowNull: false,
8
+ primaryKey: true,
9
+ references: {
10
+ model: 'Competition',
11
+ key: 'competition_id'
12
+ }
13
+ },
14
+ team_id: {
15
+ type: DataTypes.UUID,
16
+ allowNull: false,
17
+ primaryKey: true,
18
+ references: {
19
+ model: 'Team',
20
+ key: 'team_id'
21
+ }
22
+ },
23
+ won30: { type: DataTypes.INTEGER, allowNull: false },
24
+ won31: { type: DataTypes.INTEGER, allowNull: false },
25
+ won32: { type: DataTypes.INTEGER, allowNull: false },
26
+ lost03: { type: DataTypes.INTEGER, allowNull: false },
27
+ lost13: { type: DataTypes.INTEGER, allowNull: false },
28
+ lost23: { type: DataTypes.INTEGER, allowNull: false },
29
+ points_won: { type: DataTypes.INTEGER, allowNull: false },
30
+ points_lost: { type: DataTypes.INTEGER, allowNull: false },
31
+ points: { type: DataTypes.INTEGER, allowNull: false },
32
+ sets_won: { type: DataTypes.INTEGER, allowNull: false },
33
+ sets_lost: { type: DataTypes.INTEGER, allowNull: false },
34
+ matches_won: { type: DataTypes.INTEGER, allowNull: false },
35
+ matches_lost: { type: DataTypes.INTEGER, allowNull: false },
36
+ total_matches: { type: DataTypes.INTEGER, allowNull: false }
37
+ }, {
38
+ sequelize,
39
+ tableName: 'HistoricStandings',
40
+ schema: 'public',
41
+ timestamps: false,
42
+ indexes: [{
43
+ name: 'HistoricStandings_pk',
44
+ unique: true,
45
+ fields: [
46
+ { name: 'competition_id' },
47
+ { name: 'team_id' }
48
+ ]
49
+ }]
50
+ });
51
+ }
52
+ }
@@ -0,0 +1,3 @@
1
+ export * from './box-score-totals';
2
+ export * from './match-result';
3
+ export * from './historic-standings';
@@ -0,0 +1,3 @@
1
+ export * from './box-score-totals';
2
+ export * from './match-result';
3
+ export * from './historic-standings';
@@ -1,6 +1,6 @@
1
1
  import * as Sequelize from 'sequelize';
2
2
  import { Model } from 'sequelize';
3
- import { MatchId, MatchModel, TeamId, TeamModel } from '.';
3
+ import { MatchId, MatchModel, TeamId, TeamModel } from '..';
4
4
  export interface MatchResultAttributes {
5
5
  match_id: string;
6
6
  home_score: number;
@@ -19,9 +19,9 @@ export declare class MatchResultModel extends Model<MatchResultAttributes, Match
19
19
  getMatch: Sequelize.BelongsToGetAssociationMixin<MatchModel>;
20
20
  setMatch: Sequelize.BelongsToSetAssociationMixin<MatchModel, MatchId>;
21
21
  createMatch: Sequelize.BelongsToCreateAssociationMixin<MatchModel>;
22
- WinnerTeam: TeamModel;
23
- getWinnerTeam: Sequelize.BelongsToGetAssociationMixin<TeamModel>;
24
- setWinnerTeam: Sequelize.BelongsToSetAssociationMixin<TeamModel, TeamId>;
25
- createWinnerTeam: Sequelize.BelongsToCreateAssociationMixin<TeamModel>;
22
+ Winner: TeamModel;
23
+ getWinner: Sequelize.BelongsToGetAssociationMixin<TeamModel>;
24
+ setWinner: Sequelize.BelongsToSetAssociationMixin<TeamModel, TeamId>;
25
+ createWinner: Sequelize.BelongsToCreateAssociationMixin<TeamModel>;
26
26
  static initModel(sequelize: Sequelize.Sequelize): typeof MatchResultModel;
27
27
  }
@@ -21,7 +21,7 @@ export class MatchResultModel extends Model {
21
21
  }
22
22
  }, {
23
23
  sequelize,
24
- tableName: 'MatchResultView',
24
+ tableName: 'MatchResult',
25
25
  schema: 'public',
26
26
  timestamps: false,
27
27
  indexes: [{
@@ -22,7 +22,7 @@ function transformToObject(model) {
22
22
  status: model.status,
23
23
  homeScore: model.MatchResult?.home_score,
24
24
  awayScore: model.MatchResult?.away_score,
25
- winner: model.MatchResult?.WinnerTeam != null ? transformToTeam(model.MatchResult.WinnerTeam) : undefined
25
+ winner: model.MatchResult?.Winner != null ? transformToTeam(model.MatchResult.Winner) : undefined
26
26
  });
27
27
  }
28
28
  export { transformToObject as transformToMatch, transformToAttributes as transformFromMatch };
@@ -23,6 +23,5 @@ export declare class Season {
23
23
  champion?: Team;
24
24
  constructor({ id, iteration, teams, matches, champion, status, divisionId }: SeasonOpts);
25
25
  calculateStandings(): Standing[];
26
- updateStandings(): void;
27
26
  }
28
27
  export {};
@@ -17,13 +17,4 @@ export class Season {
17
17
  return standing;
18
18
  }).sort(Standing.sortFn);
19
19
  }
20
- updateStandings() {
21
- if (this.matches == null || this.matches.length < 1)
22
- throw new Error('NO_MATCHES');
23
- this.standings.length = 0;
24
- this.standings.push(...this.calculateStandings());
25
- if (this.matches.every((match) => match.isOver())) {
26
- this.champion = this.standings[0].team;
27
- }
28
- }
29
20
  }
@@ -40,8 +40,6 @@ export class Standing {
40
40
  .filter(match => match.isOver());
41
41
  let teamSide;
42
42
  let otherSide;
43
- let teamScore;
44
- let otherScore;
45
43
  for (const match of matches) {
46
44
  if (this.team.id === match.homeTeam.id) {
47
45
  teamSide = MatchTeam.HOME;
@@ -57,11 +55,9 @@ export class Standing {
57
55
  else {
58
56
  this[`lost${match.getTeamSets(teamSide)}3`]++;
59
57
  }
60
- teamScore = `${teamSide === MatchTeam.HOME ? 'home' : 'away'}Score`;
61
- otherScore = `${otherSide === MatchTeam.HOME ? 'home' : 'away'}Score`;
62
58
  for (const set of match.sets) {
63
- this.pointsWon += set[teamScore];
64
- this.pointsLost += set[otherScore];
59
+ this.pointsWon += set[teamSide === MatchTeam.HOME ? 'homeScore' : 'awayScore'];
60
+ this.pointsLost += set[otherSide === MatchTeam.HOME ? 'homeScore' : 'awayScore'];
65
61
  }
66
62
  }
67
63
  this.points = (this.won30 + this.won31) * 3 + this.won32 * 2 + this.lost23;
@@ -13,14 +13,8 @@ interface MatchParams {
13
13
  awayScore?: number;
14
14
  winner?: Team;
15
15
  }
16
- export declare enum MatchScore {
17
- '3-0' = "3-0",
18
- '3-1' = "3-1",
19
- '3-2' = "3-2",
20
- '2-3' = "2-3",
21
- '1-3' = "1-3",
22
- '0-3' = "0-3"
23
- }
16
+ export type MatchScore = '3-0' | '3-1' | '3-2' | '2-3' | '1-3' | '0-3';
17
+ export type SetScore = 0 | 1 | 2 | 3;
24
18
  export declare class Match {
25
19
  readonly id: string;
26
20
  readonly homeTeam: Team;
@@ -33,7 +27,7 @@ export declare class Match {
33
27
  status: StatusEnum;
34
28
  constructor({ id, homeTeam, awayTeam, scheduledDate, sets, status, homeScore, awayScore, winner }: MatchParams);
35
29
  addSet(set: MatchSet): void;
36
- getTeamSets(team: MatchTeam): number;
30
+ getTeamSets(team: MatchTeam): SetScore;
37
31
  getScore(): MatchScore;
38
32
  isOver(): boolean;
39
33
  getWinner(): Team;
@@ -1,15 +1,6 @@
1
1
  import { validateUUID } from '../utils';
2
2
  import { MatchTeam } from './match-team';
3
3
  import { StatusEnum } from '../../data';
4
- export var MatchScore;
5
- (function (MatchScore) {
6
- MatchScore["3-0"] = "3-0";
7
- MatchScore["3-1"] = "3-1";
8
- MatchScore["3-2"] = "3-2";
9
- MatchScore["2-3"] = "2-3";
10
- MatchScore["1-3"] = "1-3";
11
- MatchScore["0-3"] = "0-3";
12
- })(MatchScore || (MatchScore = {}));
13
4
  export class Match {
14
5
  constructor({ id, homeTeam, awayTeam, scheduledDate, sets, status, homeScore, awayScore, winner }) {
15
6
  validateUUID(id);
@@ -29,7 +20,10 @@ export class Match {
29
20
  this.sets.push(set);
30
21
  }
31
22
  getTeamSets(team) {
32
- return this.sets.reduce((sets, set) => sets + (!set.isOver() ? 0 : set.getWinner() === team ? 1 : 0), 0);
23
+ const sets = this.sets.reduce((sets, set) => sets + (!set.isOver() ? 0 : set.getWinner() === team ? 1 : 0), 0);
24
+ if (sets > 3 || sets < 0)
25
+ throw new Error(`INCORRECT_SET_VALUE: ${sets}`);
26
+ return sets;
33
27
  }
34
28
  getScore() {
35
29
  return `${this.getTeamSets(MatchTeam.HOME)}-${this.getTeamSets(MatchTeam.AWAY)}`;
@@ -1,12 +1,10 @@
1
1
  import { CourtPosition } from './court-position';
2
2
  import { RallyEvent } from '../event';
3
- import { Team } from '../team';
4
3
  interface RallyParams {
5
4
  readonly id: string;
6
5
  readonly order: number;
7
6
  readonly servingTeamId: string;
8
7
  readonly events: RallyEvent[];
9
- winner?: Team;
10
8
  }
11
9
  export interface PlayerPosition {
12
10
  position: CourtPosition;
@@ -17,8 +15,7 @@ export declare class Rally {
17
15
  readonly servingTeamId: string;
18
16
  readonly events: RallyEvent[];
19
17
  readonly order: number;
20
- winner?: Team;
21
- constructor({ id, order, servingTeamId, events, winner }: RallyParams);
18
+ constructor({ id, order, servingTeamId, events }: RallyParams);
22
19
  addEvent(event: RallyEvent): void;
23
20
  }
24
21
  export {};
@@ -1,12 +1,11 @@
1
1
  import { validateUUID } from '../utils';
2
2
  export class Rally {
3
- constructor({ id, order, servingTeamId, events, winner }) {
3
+ constructor({ id, order, servingTeamId, events }) {
4
4
  validateUUID(id);
5
5
  this.id = id;
6
6
  this.order = order;
7
7
  this.servingTeamId = servingTeamId;
8
8
  this.events = events;
9
- this.winner = winner;
10
9
  }
11
10
  addEvent(event) {
12
11
  this.events.push(event);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.202",
3
+ "version": "0.0.204",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",