hockey-blast-common-lib 0.1.63__py3-none-any.whl → 0.1.64__py3-none-any.whl
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.
- hockey_blast_common_lib/aggregate_all_stats.py +7 -4
- hockey_blast_common_lib/aggregate_goalie_stats.py +301 -107
- hockey_blast_common_lib/aggregate_h2h_stats.py +64 -33
- hockey_blast_common_lib/aggregate_human_stats.py +565 -280
- hockey_blast_common_lib/aggregate_referee_stats.py +286 -135
- hockey_blast_common_lib/aggregate_s2s_stats.py +85 -25
- hockey_blast_common_lib/aggregate_scorekeeper_stats.py +228 -113
- hockey_blast_common_lib/aggregate_skater_stats.py +561 -238
- hockey_blast_common_lib/assign_skater_skill.py +21 -11
- hockey_blast_common_lib/db_connection.py +59 -8
- hockey_blast_common_lib/embedding_utils.py +309 -0
- hockey_blast_common_lib/h2h_models.py +150 -56
- hockey_blast_common_lib/models.py +305 -150
- hockey_blast_common_lib/options.py +30 -15
- hockey_blast_common_lib/progress_utils.py +21 -13
- hockey_blast_common_lib/skills_in_divisions.py +170 -33
- hockey_blast_common_lib/skills_propagation.py +164 -70
- hockey_blast_common_lib/stats_models.py +489 -245
- hockey_blast_common_lib/stats_utils.py +6 -3
- hockey_blast_common_lib/utils.py +89 -25
- hockey_blast_common_lib/wsgi.py +7 -5
- {hockey_blast_common_lib-0.1.63.dist-info → hockey_blast_common_lib-0.1.64.dist-info}/METADATA +1 -1
- hockey_blast_common_lib-0.1.64.dist-info/RECORD +29 -0
- hockey_blast_common_lib-0.1.63.dist-info/RECORD +0 -28
- {hockey_blast_common_lib-0.1.63.dist-info → hockey_blast_common_lib-0.1.64.dist-info}/WHEEL +0 -0
- {hockey_blast_common_lib-0.1.63.dist-info → hockey_blast_common_lib-0.1.64.dist-info}/top_level.txt +0 -0
|
@@ -1,89 +1,182 @@
|
|
|
1
1
|
from hockey_blast_common_lib.models import db
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
class H2HStats(db.Model):
|
|
4
|
-
__tablename__ =
|
|
5
|
+
__tablename__ = "h2h_stats"
|
|
5
6
|
id = db.Column(db.Integer, primary_key=True)
|
|
6
|
-
human1_id = db.Column(db.Integer, db.ForeignKey(
|
|
7
|
-
human2_id = db.Column(db.Integer, db.ForeignKey(
|
|
7
|
+
human1_id = db.Column(db.Integer, db.ForeignKey("humans.id"), nullable=False)
|
|
8
|
+
human2_id = db.Column(db.Integer, db.ForeignKey("humans.id"), nullable=False)
|
|
8
9
|
# Always store with human1_id < human2_id for uniqueness
|
|
9
10
|
__table_args__ = (
|
|
10
|
-
db.UniqueConstraint(
|
|
11
|
-
db.Index(
|
|
11
|
+
db.UniqueConstraint("human1_id", "human2_id", name="_h2h_human_pair_uc"),
|
|
12
|
+
db.Index(
|
|
13
|
+
"ix_h2h_human_pair", "human1_id", "human2_id"
|
|
14
|
+
), # Composite index for fast lookup
|
|
12
15
|
)
|
|
13
16
|
|
|
14
17
|
# General
|
|
15
|
-
games_together = db.Column(
|
|
16
|
-
|
|
18
|
+
games_together = db.Column(
|
|
19
|
+
db.Integer, default=0, nullable=False
|
|
20
|
+
) # Games where both played (any role, any team)
|
|
21
|
+
games_against = db.Column(
|
|
22
|
+
db.Integer, default=0, nullable=False
|
|
23
|
+
) # Games where both played on opposing teams
|
|
17
24
|
games_tied_together = db.Column(db.Integer, default=0, nullable=False)
|
|
18
|
-
games_tied_against = db.Column(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
games_tied_against = db.Column(
|
|
26
|
+
db.Integer, default=0, nullable=False
|
|
27
|
+
) # Games against each other that ended in a tie
|
|
28
|
+
wins_together = db.Column(
|
|
29
|
+
db.Integer, default=0, nullable=False
|
|
30
|
+
) # Games both played on same team and won
|
|
31
|
+
losses_together = db.Column(
|
|
32
|
+
db.Integer, default=0, nullable=False
|
|
33
|
+
) # Games both played on same team and lost
|
|
34
|
+
h1_wins_vs_h2 = db.Column(
|
|
35
|
+
db.Integer, default=0, nullable=False
|
|
36
|
+
) # Games h1's team won vs h2's team
|
|
37
|
+
h2_wins_vs_h1 = db.Column(
|
|
38
|
+
db.Integer, default=0, nullable=False
|
|
39
|
+
) # Games h2's team won vs h1's team
|
|
23
40
|
|
|
24
41
|
# Role-specific counts
|
|
25
|
-
games_h1_goalie = db.Column(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
42
|
+
games_h1_goalie = db.Column(
|
|
43
|
+
db.Integer, default=0, nullable=False
|
|
44
|
+
) # Games where h1 was a goalie and h2 played
|
|
45
|
+
games_h2_goalie = db.Column(
|
|
46
|
+
db.Integer, default=0, nullable=False
|
|
47
|
+
) # Games where h2 was a goalie and h1 played
|
|
48
|
+
games_h1_ref = db.Column(
|
|
49
|
+
db.Integer, default=0, nullable=False
|
|
50
|
+
) # Games where h1 was a referee and h2 played
|
|
51
|
+
games_h2_ref = db.Column(
|
|
52
|
+
db.Integer, default=0, nullable=False
|
|
53
|
+
) # Games where h2 was a referee and h1 played
|
|
54
|
+
games_both_referees = db.Column(
|
|
55
|
+
db.Integer, default=0, nullable=False
|
|
56
|
+
) # Games where both were referees
|
|
30
57
|
|
|
31
58
|
# Goals/Assists/Penalties (when both played)
|
|
32
|
-
goals_h1_when_together = db.Column(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
59
|
+
goals_h1_when_together = db.Column(
|
|
60
|
+
db.Integer, default=0, nullable=False
|
|
61
|
+
) # Goals by h1 when both played
|
|
62
|
+
goals_h2_when_together = db.Column(
|
|
63
|
+
db.Integer, default=0, nullable=False
|
|
64
|
+
) # Goals by h2 when both played
|
|
65
|
+
assists_h1_when_together = db.Column(
|
|
66
|
+
db.Integer, default=0, nullable=False
|
|
67
|
+
) # Assists by h1 when both played
|
|
68
|
+
assists_h2_when_together = db.Column(
|
|
69
|
+
db.Integer, default=0, nullable=False
|
|
70
|
+
) # Assists by h2 when both played
|
|
71
|
+
penalties_h1_when_together = db.Column(
|
|
72
|
+
db.Integer, default=0, nullable=False
|
|
73
|
+
) # Penalties on h1 when both played
|
|
74
|
+
penalties_h2_when_together = db.Column(
|
|
75
|
+
db.Integer, default=0, nullable=False
|
|
76
|
+
) # Penalties on h2 when both played
|
|
77
|
+
gm_penalties_h1_when_together = db.Column(
|
|
78
|
+
db.Integer, default=0, nullable=False
|
|
79
|
+
) # GM penalties on h1 when both played
|
|
80
|
+
gm_penalties_h2_when_together = db.Column(
|
|
81
|
+
db.Integer, default=0, nullable=False
|
|
82
|
+
) # GM penalties on h2 when both played
|
|
40
83
|
|
|
41
84
|
# Goalie/Skater head-to-head (when one is goalie, other is skater on opposing team)
|
|
42
|
-
h1_goalie_h2_scorer_goals = db.Column(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
85
|
+
h1_goalie_h2_scorer_goals = db.Column(
|
|
86
|
+
db.Integer, default=0, nullable=False
|
|
87
|
+
) # Goals scored by h2 against h1 as goalie
|
|
88
|
+
h2_goalie_h1_scorer_goals = db.Column(
|
|
89
|
+
db.Integer, default=0, nullable=False
|
|
90
|
+
) # Goals scored by h1 against h2 as goalie
|
|
91
|
+
shots_faced_h1_goalie_vs_h2 = db.Column(
|
|
92
|
+
db.Integer, default=0, nullable=False
|
|
93
|
+
) # Shots faced by h1 as goalie vs h2 as skater
|
|
94
|
+
shots_faced_h2_goalie_vs_h1 = db.Column(
|
|
95
|
+
db.Integer, default=0, nullable=False
|
|
96
|
+
) # Shots faced by h2 as goalie vs h1 as skater
|
|
97
|
+
goals_allowed_h1_goalie_vs_h2 = db.Column(
|
|
98
|
+
db.Integer, default=0, nullable=False
|
|
99
|
+
) # Goals allowed by h1 as goalie vs h2 as skater
|
|
100
|
+
goals_allowed_h2_goalie_vs_h1 = db.Column(
|
|
101
|
+
db.Integer, default=0, nullable=False
|
|
102
|
+
) # Goals allowed by h2 as goalie vs h1 as skater
|
|
103
|
+
save_percentage_h1_goalie_vs_h2 = db.Column(
|
|
104
|
+
db.Float, default=0.0, nullable=False
|
|
105
|
+
) # Save % by h1 as goalie vs h2 as skater
|
|
106
|
+
save_percentage_h2_goalie_vs_h1 = db.Column(
|
|
107
|
+
db.Float, default=0.0, nullable=False
|
|
108
|
+
) # Save % by h2 as goalie vs h1 as skater
|
|
50
109
|
|
|
51
110
|
# Referee/Player
|
|
52
|
-
h1_ref_h2_player_games = db.Column(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
111
|
+
h1_ref_h2_player_games = db.Column(
|
|
112
|
+
db.Integer, default=0, nullable=False
|
|
113
|
+
) # Games h1 was referee, h2 was player
|
|
114
|
+
h2_ref_h1_player_games = db.Column(
|
|
115
|
+
db.Integer, default=0, nullable=False
|
|
116
|
+
) # Games h2 was referee, h1 was player
|
|
117
|
+
h1_ref_penalties_on_h2 = db.Column(
|
|
118
|
+
db.Integer, default=0, nullable=False
|
|
119
|
+
) # Penalties given by h1 (as ref) to h2
|
|
120
|
+
h2_ref_penalties_on_h1 = db.Column(
|
|
121
|
+
db.Integer, default=0, nullable=False
|
|
122
|
+
) # Penalties given by h2 (as ref) to h1
|
|
123
|
+
h1_ref_gm_penalties_on_h2 = db.Column(
|
|
124
|
+
db.Integer, default=0, nullable=False
|
|
125
|
+
) # GM penalties given by h1 (as ref) to h2
|
|
126
|
+
h2_ref_gm_penalties_on_h1 = db.Column(
|
|
127
|
+
db.Integer, default=0, nullable=False
|
|
128
|
+
) # GM penalties given by h2 (as ref) to h1
|
|
58
129
|
|
|
59
130
|
# Both referees (when both are referees in the same game)
|
|
60
|
-
penalties_given_both_refs = db.Column(
|
|
61
|
-
|
|
131
|
+
penalties_given_both_refs = db.Column(
|
|
132
|
+
db.Integer, default=0, nullable=False
|
|
133
|
+
) # Total penalties given by both
|
|
134
|
+
gm_penalties_given_both_refs = db.Column(
|
|
135
|
+
db.Integer, default=0, nullable=False
|
|
136
|
+
) # Total GM penalties given by both
|
|
62
137
|
|
|
63
138
|
# Shootouts
|
|
64
|
-
h1_shootout_attempts_vs_h2_goalie = db.Column(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
139
|
+
h1_shootout_attempts_vs_h2_goalie = db.Column(
|
|
140
|
+
db.Integer, default=0, nullable=False
|
|
141
|
+
) # h1 shootout attempts vs h2 as goalie
|
|
142
|
+
h1_shootout_goals_vs_h2_goalie = db.Column(
|
|
143
|
+
db.Integer, default=0, nullable=False
|
|
144
|
+
) # h1 shootout goals vs h2 as goalie
|
|
145
|
+
h2_shootout_attempts_vs_h1_goalie = db.Column(
|
|
146
|
+
db.Integer, default=0, nullable=False
|
|
147
|
+
) # h2 shootout attempts vs h1 as goalie
|
|
148
|
+
h2_shootout_goals_vs_h1_goalie = db.Column(
|
|
149
|
+
db.Integer, default=0, nullable=False
|
|
150
|
+
) # h2 shootout goals vs h1 as goalie
|
|
68
151
|
|
|
69
152
|
# First and last game IDs where both were present
|
|
70
|
-
first_game_id = db.Column(
|
|
71
|
-
|
|
153
|
+
first_game_id = db.Column(
|
|
154
|
+
db.Integer, nullable=False
|
|
155
|
+
) # Game.id of the first game where both were present
|
|
156
|
+
last_game_id = db.Column(
|
|
157
|
+
db.Integer, nullable=False
|
|
158
|
+
) # Game.id of the most recent game where both were present
|
|
159
|
+
|
|
72
160
|
|
|
73
161
|
class H2HStatsMeta(db.Model):
|
|
74
|
-
__tablename__ =
|
|
162
|
+
__tablename__ = "h2h_stats_meta"
|
|
75
163
|
id = db.Column(db.Integer, primary_key=True)
|
|
76
|
-
last_run_timestamp = db.Column(
|
|
77
|
-
|
|
164
|
+
last_run_timestamp = db.Column(
|
|
165
|
+
db.DateTime, nullable=True
|
|
166
|
+
) # When the h2h stats were last updated
|
|
167
|
+
last_processed_game_id = db.Column(
|
|
168
|
+
db.Integer, nullable=True
|
|
169
|
+
) # Game.id of the latest processed game
|
|
170
|
+
|
|
78
171
|
|
|
79
172
|
class SkaterToSkaterStats(db.Model):
|
|
80
|
-
__tablename__ =
|
|
173
|
+
__tablename__ = "skater_to_skater_stats"
|
|
81
174
|
id = db.Column(db.Integer, primary_key=True)
|
|
82
|
-
skater1_id = db.Column(db.Integer, db.ForeignKey(
|
|
83
|
-
skater2_id = db.Column(db.Integer, db.ForeignKey(
|
|
175
|
+
skater1_id = db.Column(db.Integer, db.ForeignKey("humans.id"), nullable=False)
|
|
176
|
+
skater2_id = db.Column(db.Integer, db.ForeignKey("humans.id"), nullable=False)
|
|
84
177
|
__table_args__ = (
|
|
85
|
-
db.UniqueConstraint(
|
|
86
|
-
db.Index(
|
|
178
|
+
db.UniqueConstraint("skater1_id", "skater2_id", name="_s2s_skater_pair_uc"),
|
|
179
|
+
db.Index("ix_s2s_skater_pair", "skater1_id", "skater2_id"),
|
|
87
180
|
)
|
|
88
181
|
|
|
89
182
|
# General stats
|
|
@@ -100,8 +193,9 @@ class SkaterToSkaterStats(db.Model):
|
|
|
100
193
|
skater1_penalties_against_skater2 = db.Column(db.Integer, default=0, nullable=False)
|
|
101
194
|
skater2_penalties_against_skater1 = db.Column(db.Integer, default=0, nullable=False)
|
|
102
195
|
|
|
196
|
+
|
|
103
197
|
class SkaterToSkaterStatsMeta(db.Model):
|
|
104
|
-
__tablename__ =
|
|
198
|
+
__tablename__ = "skater_to_skater_stats_meta"
|
|
105
199
|
id = db.Column(db.Integer, primary_key=True)
|
|
106
200
|
last_run_timestamp = db.Column(db.DateTime, nullable=True)
|
|
107
201
|
last_processed_game_id = db.Column(db.Integer, nullable=True)
|