hockey-blast-common-lib 0.1.39__py3-none-any.whl → 0.1.41__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_goalie_stats.py +18 -12
- hockey_blast_common_lib/aggregate_human_stats.py +47 -47
- hockey_blast_common_lib/aggregate_referee_stats.py +20 -18
- hockey_blast_common_lib/aggregate_skater_stats.py +37 -26
- hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz +0 -0
- hockey_blast_common_lib/stats_models.py +5 -0
- {hockey_blast_common_lib-0.1.39.dist-info → hockey_blast_common_lib-0.1.41.dist-info}/METADATA +1 -1
- {hockey_blast_common_lib-0.1.39.dist-info → hockey_blast_common_lib-0.1.41.dist-info}/RECORD +10 -10
- {hockey_blast_common_lib-0.1.39.dist-info → hockey_blast_common_lib-0.1.41.dist-info}/WHEEL +0 -0
- {hockey_blast_common_lib-0.1.39.dist-info → hockey_blast_common_lib-0.1.41.dist-info}/top_level.txt +0 -0
@@ -88,18 +88,24 @@ def aggregate_goalie_stats(session, aggregation_type, aggregation_id, names_to_f
|
|
88
88
|
if stat.human_id in human_ids_to_filter:
|
89
89
|
continue
|
90
90
|
key = (aggregation_id, stat.human_id)
|
91
|
-
if
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
91
|
+
if key not in stats_dict:
|
92
|
+
stats_dict[key] = {
|
93
|
+
'games_played': 0,
|
94
|
+
'goals_allowed': 0,
|
95
|
+
'shots_faced': 0,
|
96
|
+
'goals_allowed_per_game': 0.0,
|
97
|
+
'save_percentage': 0.0,
|
98
|
+
'game_ids': [],
|
99
|
+
'first_game_id': None,
|
100
|
+
'last_game_id': None
|
101
|
+
}
|
102
|
+
stats_dict[key]['games_played'] += stat.games_played
|
103
|
+
stats_dict[key]['goals_allowed'] += stat.goals_allowed if stat.goals_allowed is not None else 0
|
104
|
+
stats_dict[key]['shots_faced'] += stat.shots_faced if stat.shots_faced is not None else 0
|
105
|
+
stats_dict[key]['game_ids'].extend(stat.game_ids)
|
106
|
+
|
107
|
+
# Filter out entries with games_played less than min_games
|
108
|
+
stats_dict = {key: value for key, value in stats_dict.items() if value['games_played'] >= min_games}
|
103
109
|
|
104
110
|
# Calculate per game stats
|
105
111
|
for key, stat in stats_dict.items():
|
@@ -113,25 +113,29 @@ def aggregate_human_stats(session, aggregation_type, aggregation_id, names_to_fi
|
|
113
113
|
if stat.human_id in human_ids_to_filter:
|
114
114
|
continue
|
115
115
|
key = (aggregation_id, stat.human_id)
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
116
|
+
if key not in stats_dict:
|
117
|
+
stats_dict[key] = {
|
118
|
+
'games_total': 0,
|
119
|
+
'games_skater': 0,
|
120
|
+
'games_goalie': 0,
|
121
|
+
'games_referee': 0,
|
122
|
+
'games_scorekeeper': 0,
|
123
|
+
'skater_game_ids': [],
|
124
|
+
'goalie_game_ids': [],
|
125
|
+
'referee_game_ids': [],
|
126
|
+
'scorekeeper_game_ids': [],
|
127
|
+
'first_game_id_skater': None,
|
128
|
+
'last_game_id_skater': None,
|
129
|
+
'first_game_id_goalie': None,
|
130
|
+
'last_game_id_goalie': None,
|
131
|
+
'first_game_id_referee': None,
|
132
|
+
'last_game_id_referee': None,
|
133
|
+
'first_game_id_scorekeeper': None,
|
134
|
+
'last_game_id_scorekeeper': None
|
135
|
+
}
|
136
|
+
stats_dict[key]['games_total'] += stat.games_skater
|
137
|
+
stats_dict[key]['games_skater'] += stat.games_skater
|
138
|
+
stats_dict[key]['skater_game_ids'].extend(stat.skater_game_ids)
|
135
139
|
|
136
140
|
for stat in goalie_stats:
|
137
141
|
if stat.human_id in human_ids_to_filter:
|
@@ -139,13 +143,13 @@ def aggregate_human_stats(session, aggregation_type, aggregation_id, names_to_fi
|
|
139
143
|
key = (aggregation_id, stat.human_id)
|
140
144
|
if key not in stats_dict:
|
141
145
|
stats_dict[key] = {
|
142
|
-
'games_total':
|
146
|
+
'games_total': 0,
|
143
147
|
'games_skater': 0,
|
144
|
-
'games_goalie':
|
148
|
+
'games_goalie': 0,
|
145
149
|
'games_referee': 0,
|
146
150
|
'games_scorekeeper': 0,
|
147
151
|
'skater_game_ids': [],
|
148
|
-
'goalie_game_ids':
|
152
|
+
'goalie_game_ids': [],
|
149
153
|
'referee_game_ids': [],
|
150
154
|
'scorekeeper_game_ids': [],
|
151
155
|
'first_game_id_skater': None,
|
@@ -157,10 +161,9 @@ def aggregate_human_stats(session, aggregation_type, aggregation_id, names_to_fi
|
|
157
161
|
'first_game_id_scorekeeper': None,
|
158
162
|
'last_game_id_scorekeeper': None
|
159
163
|
}
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
stats_dict[key]['goalie_game_ids'] += stat.goalie_game_ids
|
164
|
+
stats_dict[key]['games_total'] += stat.games_goalie
|
165
|
+
stats_dict[key]['games_goalie'] += stat.games_goalie
|
166
|
+
stats_dict[key]['goalie_game_ids'].extend(stat.goalie_game_ids)
|
164
167
|
|
165
168
|
for stat in referee_stats:
|
166
169
|
if stat.human_id in human_ids_to_filter:
|
@@ -168,14 +171,14 @@ def aggregate_human_stats(session, aggregation_type, aggregation_id, names_to_fi
|
|
168
171
|
key = (aggregation_id, stat.human_id)
|
169
172
|
if key not in stats_dict:
|
170
173
|
stats_dict[key] = {
|
171
|
-
'games_total':
|
174
|
+
'games_total': 0,
|
172
175
|
'games_skater': 0,
|
173
176
|
'games_goalie': 0,
|
174
|
-
'games_referee':
|
177
|
+
'games_referee': 0,
|
175
178
|
'games_scorekeeper': 0,
|
176
179
|
'skater_game_ids': [],
|
177
180
|
'goalie_game_ids': [],
|
178
|
-
'referee_game_ids':
|
181
|
+
'referee_game_ids': [],
|
179
182
|
'scorekeeper_game_ids': [],
|
180
183
|
'first_game_id_skater': None,
|
181
184
|
'last_game_id_skater': None,
|
@@ -186,10 +189,9 @@ def aggregate_human_stats(session, aggregation_type, aggregation_id, names_to_fi
|
|
186
189
|
'first_game_id_scorekeeper': None,
|
187
190
|
'last_game_id_scorekeeper': None
|
188
191
|
}
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
stats_dict[key]['referee_game_ids'] += stat.referee_game_ids
|
192
|
+
stats_dict[key]['games_total'] += stat.games_referee
|
193
|
+
stats_dict[key]['games_referee'] += stat.games_referee
|
194
|
+
stats_dict[key]['referee_game_ids'].extend(stat.referee_game_ids)
|
193
195
|
|
194
196
|
for stat in referee_stats_2:
|
195
197
|
if stat.human_id in human_ids_to_filter:
|
@@ -197,14 +199,14 @@ def aggregate_human_stats(session, aggregation_type, aggregation_id, names_to_fi
|
|
197
199
|
key = (aggregation_id, stat.human_id)
|
198
200
|
if key not in stats_dict:
|
199
201
|
stats_dict[key] = {
|
200
|
-
'games_total':
|
202
|
+
'games_total': 0,
|
201
203
|
'games_skater': 0,
|
202
204
|
'games_goalie': 0,
|
203
|
-
'games_referee':
|
205
|
+
'games_referee': 0,
|
204
206
|
'games_scorekeeper': 0,
|
205
207
|
'skater_game_ids': [],
|
206
208
|
'goalie_game_ids': [],
|
207
|
-
'referee_game_ids':
|
209
|
+
'referee_game_ids': [],
|
208
210
|
'scorekeeper_game_ids': [],
|
209
211
|
'first_game_id_skater': None,
|
210
212
|
'last_game_id_skater': None,
|
@@ -215,10 +217,9 @@ def aggregate_human_stats(session, aggregation_type, aggregation_id, names_to_fi
|
|
215
217
|
'first_game_id_scorekeeper': None,
|
216
218
|
'last_game_id_scorekeeper': None
|
217
219
|
}
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
stats_dict[key]['referee_game_ids'] += stat.referee_game_ids
|
220
|
+
stats_dict[key]['games_total'] += stat.games_referee
|
221
|
+
stats_dict[key]['games_referee'] += stat.games_referee
|
222
|
+
stats_dict[key]['referee_game_ids'].extend(stat.referee_game_ids)
|
222
223
|
|
223
224
|
for stat in scorekeeper_stats:
|
224
225
|
if stat.human_id in human_ids_to_filter:
|
@@ -226,15 +227,15 @@ def aggregate_human_stats(session, aggregation_type, aggregation_id, names_to_fi
|
|
226
227
|
key = (aggregation_id, stat.human_id)
|
227
228
|
if key not in stats_dict:
|
228
229
|
stats_dict[key] = {
|
229
|
-
'games_total':
|
230
|
+
'games_total': 0,
|
230
231
|
'games_skater': 0,
|
231
232
|
'games_goalie': 0,
|
232
233
|
'games_referee': 0,
|
233
|
-
'games_scorekeeper':
|
234
|
+
'games_scorekeeper': 0,
|
234
235
|
'skater_game_ids': [],
|
235
236
|
'goalie_game_ids': [],
|
236
237
|
'referee_game_ids': [],
|
237
|
-
'scorekeeper_game_ids':
|
238
|
+
'scorekeeper_game_ids': [],
|
238
239
|
'first_game_id_skater': None,
|
239
240
|
'last_game_id_skater': None,
|
240
241
|
'first_game_id_goalie': None,
|
@@ -244,10 +245,9 @@ def aggregate_human_stats(session, aggregation_type, aggregation_id, names_to_fi
|
|
244
245
|
'first_game_id_scorekeeper': None,
|
245
246
|
'last_game_id_scorekeeper': None
|
246
247
|
}
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
stats_dict[key]['scorekeeper_game_ids'] += stat.scorekeeper_game_ids
|
248
|
+
stats_dict[key]['games_total'] += stat.games_scorekeeper
|
249
|
+
stats_dict[key]['games_scorekeeper'] += stat.games_scorekeeper
|
250
|
+
stats_dict[key]['scorekeeper_game_ids'].extend(stat.scorekeeper_game_ids)
|
251
251
|
|
252
252
|
# Ensure all keys have valid human_id values
|
253
253
|
stats_dict = {key: value for key, value in stats_dict.items() if key[1] is not None}
|
@@ -94,16 +94,19 @@ def aggregate_referee_stats(session, aggregation_type, aggregation_id, names_to_
|
|
94
94
|
if stat.human_id in human_ids_to_filter:
|
95
95
|
continue
|
96
96
|
key = (aggregation_id, stat.human_id)
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
97
|
+
if key not in stats_dict:
|
98
|
+
stats_dict[key] = {
|
99
|
+
'games_reffed': 0,
|
100
|
+
'penalties_given': 0,
|
101
|
+
'gm_given': 0,
|
102
|
+
'penalties_per_game': 0.0,
|
103
|
+
'gm_per_game': 0.0,
|
104
|
+
'game_ids': [],
|
105
|
+
'first_game_id': None,
|
106
|
+
'last_game_id': None
|
107
|
+
}
|
108
|
+
stats_dict[key]['games_reffed'] += stat.games_reffed
|
109
|
+
stats_dict[key]['game_ids'].extend(stat.game_ids)
|
107
110
|
|
108
111
|
for stat in games_reffed_stats_2:
|
109
112
|
if stat.human_id in human_ids_to_filter:
|
@@ -111,18 +114,20 @@ def aggregate_referee_stats(session, aggregation_type, aggregation_id, names_to_
|
|
111
114
|
key = (aggregation_id, stat.human_id)
|
112
115
|
if key not in stats_dict:
|
113
116
|
stats_dict[key] = {
|
114
|
-
'games_reffed':
|
117
|
+
'games_reffed': 0,
|
115
118
|
'penalties_given': 0,
|
116
119
|
'gm_given': 0,
|
117
120
|
'penalties_per_game': 0.0,
|
118
121
|
'gm_per_game': 0.0,
|
119
|
-
'game_ids':
|
122
|
+
'game_ids': [],
|
120
123
|
'first_game_id': None,
|
121
124
|
'last_game_id': None
|
122
125
|
}
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
+
stats_dict[key]['games_reffed'] += stat.games_reffed
|
127
|
+
stats_dict[key]['game_ids'].extend(stat.game_ids)
|
128
|
+
|
129
|
+
# Filter out entries with games_reffed less than min_games
|
130
|
+
stats_dict = {key: value for key, value in stats_dict.items() if value['games_reffed'] >= min_games}
|
126
131
|
|
127
132
|
for stat in penalties_given_stats:
|
128
133
|
if stat.referee_1_id and stat.referee_1_id not in human_ids_to_filter:
|
@@ -148,9 +153,6 @@ def aggregate_referee_stats(session, aggregation_type, aggregation_id, names_to_
|
|
148
153
|
# Ensure all keys have valid human_id values
|
149
154
|
stats_dict = {key: value for key, value in stats_dict.items() if key[1] is not None}
|
150
155
|
|
151
|
-
# Filter out referees with less than min_games
|
152
|
-
stats_dict = {key: value for key, value in stats_dict.items() if value['games_reffed'] >= min_games}
|
153
|
-
|
154
156
|
# Populate first_game_id and last_game_id
|
155
157
|
for key, stat in stats_dict.items():
|
156
158
|
all_game_ids = stat['game_ids']
|
@@ -84,42 +84,38 @@ def aggregate_skater_stats(session, aggregation_type, aggregation_id, names_to_f
|
|
84
84
|
|
85
85
|
# Aggregate games played for each human in each division, excluding goalies
|
86
86
|
games_played_stats = session.query(
|
87
|
-
Game.org_id,
|
88
87
|
GameRoster.human_id,
|
89
88
|
func.count(Game.id).label('games_played'),
|
90
89
|
func.array_agg(Game.id).label('game_ids')
|
91
|
-
).join(
|
90
|
+
).join(Game, Game.id == GameRoster.game_id).join(Division, Game.division_id == Division.id).filter(filter_condition, ~GameRoster.role.ilike('g'), *human_filter).group_by(GameRoster.human_id).all()
|
92
91
|
|
93
92
|
# Aggregate goals for each human in each division, excluding goalies
|
94
93
|
goals_stats = session.query(
|
95
|
-
Game.org_id,
|
96
94
|
Goal.goal_scorer_id.label('human_id'),
|
97
95
|
func.count(Goal.id).label('goals'),
|
98
96
|
func.array_agg(Goal.game_id).label('goal_game_ids')
|
99
|
-
).join(Game, Game.id == Goal.game_id).join(GameRoster, and_(Game.id == GameRoster.game_id, Goal.goal_scorer_id == GameRoster.human_id)).join(Division, Game.division_id == Division.id).filter(filter_condition, ~GameRoster.role.ilike('g'), *human_filter).group_by(
|
97
|
+
).join(Game, Game.id == Goal.game_id).join(GameRoster, and_(Game.id == GameRoster.game_id, Goal.goal_scorer_id == GameRoster.human_id)).join(Division, Game.division_id == Division.id).filter(filter_condition, ~GameRoster.role.ilike('g'), *human_filter).group_by(Goal.goal_scorer_id).all()
|
100
98
|
|
101
99
|
# Aggregate assists for each human in each division, excluding goalies
|
102
100
|
assists_stats = session.query(
|
103
|
-
Game.org_id,
|
104
101
|
Goal.assist_1_id.label('human_id'),
|
105
102
|
func.count(Goal.id).label('assists'),
|
106
103
|
func.array_agg(Goal.game_id).label('assist_game_ids')
|
107
|
-
).join(Game, Game.id == Goal.game_id).join(GameRoster, and_(Game.id == GameRoster.game_id, Goal.assist_1_id == GameRoster.human_id)).join(Division, Game.division_id == Division.id).filter(filter_condition, ~GameRoster.role.ilike('g'), *human_filter).group_by(
|
104
|
+
).join(Game, Game.id == Goal.game_id).join(GameRoster, and_(Game.id == GameRoster.game_id, Goal.assist_1_id == GameRoster.human_id)).join(Division, Game.division_id == Division.id).filter(filter_condition, ~GameRoster.role.ilike('g'), *human_filter).group_by(Goal.assist_1_id).all()
|
108
105
|
|
109
106
|
assists_stats_2 = session.query(
|
110
|
-
Game.org_id,
|
111
107
|
Goal.assist_2_id.label('human_id'),
|
112
108
|
func.count(Goal.id).label('assists'),
|
113
109
|
func.array_agg(Goal.game_id).label('assist_2_game_ids')
|
114
|
-
).join(Game, Game.id == Goal.game_id).join(GameRoster, and_(Game.id == GameRoster.game_id, Goal.assist_2_id == GameRoster.human_id)).join(Division, Game.division_id == Division.id).filter(filter_condition, ~GameRoster.role.ilike('g'), *human_filter).group_by(
|
110
|
+
).join(Game, Game.id == Goal.game_id).join(GameRoster, and_(Game.id == GameRoster.game_id, Goal.assist_2_id == GameRoster.human_id)).join(Division, Game.division_id == Division.id).filter(filter_condition, ~GameRoster.role.ilike('g'), *human_filter).group_by(Goal.assist_2_id).all()
|
115
111
|
|
116
112
|
# Aggregate penalties for each human in each division, excluding goalies
|
117
113
|
penalties_stats = session.query(
|
118
|
-
Game.org_id,
|
119
114
|
Penalty.penalized_player_id.label('human_id'),
|
120
115
|
func.count(Penalty.id).label('penalties'),
|
116
|
+
func.sum(case((Penalty.penalty_minutes == 'GM', 1), else_=0)).label('gm_penalties'), # New aggregation for GM penalties
|
121
117
|
func.array_agg(Penalty.game_id).label('penalty_game_ids')
|
122
|
-
).join(Game, Game.id == Penalty.game_id).join(GameRoster, and_(Game.id == GameRoster.game_id, Penalty.penalized_player_id == GameRoster.human_id)).join(Division, Game.division_id == Division.id).filter(filter_condition, ~GameRoster.role.ilike('g'), *human_filter).group_by(
|
118
|
+
).join(Game, Game.id == Penalty.game_id).join(GameRoster, and_(Game.id == GameRoster.game_id, Penalty.penalized_player_id == GameRoster.human_id)).join(Division, Game.division_id == Division.id).filter(filter_condition, ~GameRoster.role.ilike('g'), *human_filter).group_by(Penalty.penalized_player_id).all()
|
123
119
|
|
124
120
|
# Combine the results
|
125
121
|
stats_dict = {}
|
@@ -127,22 +123,28 @@ def aggregate_skater_stats(session, aggregation_type, aggregation_id, names_to_f
|
|
127
123
|
if stat.human_id in human_ids_to_filter:
|
128
124
|
continue
|
129
125
|
key = (aggregation_id, stat.human_id)
|
130
|
-
if
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
126
|
+
if key not in stats_dict:
|
127
|
+
stats_dict[key] = {
|
128
|
+
'games_played': 0,
|
129
|
+
'goals': 0,
|
130
|
+
'assists': 0,
|
131
|
+
'penalties': 0,
|
132
|
+
'gm_penalties': 0, # Initialize GM penalties
|
133
|
+
'points': 0, # Initialize points
|
134
|
+
'goals_per_game': 0.0,
|
135
|
+
'points_per_game': 0.0,
|
136
|
+
'assists_per_game': 0.0,
|
137
|
+
'penalties_per_game': 0.0,
|
138
|
+
'gm_penalties_per_game': 0.0, # Initialize GM penalties per game
|
139
|
+
'game_ids': [],
|
140
|
+
'first_game_id': None,
|
141
|
+
'last_game_id': None
|
142
|
+
}
|
143
|
+
stats_dict[key]['games_played'] += stat.games_played
|
144
|
+
stats_dict[key]['game_ids'].extend(stat.game_ids)
|
145
|
+
|
146
|
+
# Filter out entries with games_played less than min_games
|
147
|
+
stats_dict = {key: value for key, value in stats_dict.items() if value['games_played'] >= min_games}
|
146
148
|
|
147
149
|
for stat in goals_stats:
|
148
150
|
key = (aggregation_id, stat.human_id)
|
@@ -166,6 +168,7 @@ def aggregate_skater_stats(session, aggregation_type, aggregation_id, names_to_f
|
|
166
168
|
key = (aggregation_id, stat.human_id)
|
167
169
|
if key in stats_dict:
|
168
170
|
stats_dict[key]['penalties'] += stat.penalties
|
171
|
+
stats_dict[key]['gm_penalties'] += stat.gm_penalties # Update GM penalties
|
169
172
|
|
170
173
|
# Calculate per game stats
|
171
174
|
for key, stat in stats_dict.items():
|
@@ -174,6 +177,7 @@ def aggregate_skater_stats(session, aggregation_type, aggregation_id, names_to_f
|
|
174
177
|
stat['points_per_game'] = stat['points'] / stat['games_played']
|
175
178
|
stat['assists_per_game'] = stat['assists'] / stat['games_played']
|
176
179
|
stat['penalties_per_game'] = stat['penalties'] / stat['games_played']
|
180
|
+
stat['gm_penalties_per_game'] = stat['gm_penalties'] / stat['games_played'] # Calculate GM penalties per game
|
177
181
|
|
178
182
|
# Ensure all keys have valid human_id values
|
179
183
|
stats_dict = {key: value for key, value in stats_dict.items() if key[1] is not None}
|
@@ -201,10 +205,12 @@ def aggregate_skater_stats(session, aggregation_type, aggregation_id, names_to_f
|
|
201
205
|
assign_ranks(stats_dict, 'assists')
|
202
206
|
assign_ranks(stats_dict, 'points')
|
203
207
|
assign_ranks(stats_dict, 'penalties')
|
208
|
+
assign_ranks(stats_dict, 'gm_penalties') # Assign ranks for GM penalties
|
204
209
|
assign_ranks(stats_dict, 'goals_per_game')
|
205
210
|
assign_ranks(stats_dict, 'points_per_game')
|
206
211
|
assign_ranks(stats_dict, 'assists_per_game')
|
207
212
|
assign_ranks(stats_dict, 'penalties_per_game')
|
213
|
+
assign_ranks(stats_dict, 'gm_penalties_per_game') # Assign ranks for GM penalties per game
|
208
214
|
|
209
215
|
# Debug output for specific human
|
210
216
|
if debug_human_id:
|
@@ -226,6 +232,7 @@ def aggregate_skater_stats(session, aggregation_type, aggregation_id, names_to_f
|
|
226
232
|
points_per_game = (stat['goals'] + stat['assists']) / stat['games_played'] if stat['games_played'] > 0 else 0.0
|
227
233
|
assists_per_game = stat['assists'] / stat['games_played'] if stat['games_played'] > 0 else 0.0
|
228
234
|
penalties_per_game = stat['penalties'] / stat['games_played'] if stat['games_played'] > 0 else 0.0
|
235
|
+
gm_penalties_per_game = stat['gm_penalties'] / stat['games_played'] if stat['games_played'] > 0 else 0.0 # Calculate GM penalties per game
|
229
236
|
skater_stat = StatsModel(
|
230
237
|
aggregation_id=aggregation_id,
|
231
238
|
human_id=human_id,
|
@@ -234,19 +241,23 @@ def aggregate_skater_stats(session, aggregation_type, aggregation_id, names_to_f
|
|
234
241
|
assists=stat['assists'],
|
235
242
|
points=stat['goals'] + stat['assists'],
|
236
243
|
penalties=stat['penalties'],
|
244
|
+
gm_penalties=stat['gm_penalties'], # Include GM penalties
|
237
245
|
goals_per_game=goals_per_game,
|
238
246
|
points_per_game=points_per_game,
|
239
247
|
assists_per_game=assists_per_game,
|
240
248
|
penalties_per_game=penalties_per_game,
|
249
|
+
gm_penalties_per_game=gm_penalties_per_game, # Include GM penalties per game
|
241
250
|
games_played_rank=stat['games_played_rank'],
|
242
251
|
goals_rank=stat['goals_rank'],
|
243
252
|
assists_rank=stat['assists_rank'],
|
244
253
|
points_rank=stat['points_rank'],
|
245
254
|
penalties_rank=stat['penalties_rank'],
|
255
|
+
gm_penalties_rank=stat['gm_penalties_rank'], # Include GM penalties rank
|
246
256
|
goals_per_game_rank=stat['goals_per_game_rank'],
|
247
257
|
points_per_game_rank=stat['points_per_game_rank'],
|
248
258
|
assists_per_game_rank=stat['assists_per_game_rank'],
|
249
259
|
penalties_per_game_rank=stat['penalties_per_game_rank'],
|
260
|
+
gm_penalties_per_game_rank=stat['gm_penalties_per_game_rank'], # Include GM penalties per game rank
|
250
261
|
total_in_rank=total_in_rank,
|
251
262
|
first_game_id=stat['first_game_id'],
|
252
263
|
last_game_id=stat['last_game_id']
|
Binary file
|
@@ -62,6 +62,8 @@ class BaseStatsSkater(db.Model):
|
|
62
62
|
points_rank = db.Column(db.Integer, default=0)
|
63
63
|
penalties = db.Column(db.Integer, default=0)
|
64
64
|
penalties_rank = db.Column(db.Integer, default=0)
|
65
|
+
gm_penalties = db.Column(db.Integer, default=0) # New field for GM penalties
|
66
|
+
gm_penalties_rank = db.Column(db.Integer, default=0) # New field for GM penalties rank
|
65
67
|
goals_per_game = db.Column(db.Float, default=0.0)
|
66
68
|
goals_per_game_rank = db.Column(db.Integer, default=0)
|
67
69
|
points_per_game = db.Column(db.Float, default=0.0)
|
@@ -70,6 +72,8 @@ class BaseStatsSkater(db.Model):
|
|
70
72
|
assists_per_game_rank = db.Column(db.Integer, default=0)
|
71
73
|
penalties_per_game = db.Column(db.Float, default=0.0)
|
72
74
|
penalties_per_game_rank = db.Column(db.Integer, default=0)
|
75
|
+
gm_penalties_per_game = db.Column(db.Float, default=0.0)
|
76
|
+
gm_penalties_per_game_rank = db.Column(db.Integer, default=0)
|
73
77
|
total_in_rank = db.Column(db.Integer, default=0)
|
74
78
|
first_game_id = db.Column(db.Integer, db.ForeignKey('games.id'))
|
75
79
|
last_game_id = db.Column(db.Integer, db.ForeignKey('games.id'))
|
@@ -82,6 +86,7 @@ class BaseStatsSkater(db.Model):
|
|
82
86
|
db.Index(f'idx_{cls.aggregation_type}_points_per_game3', cls.get_aggregation_column(), 'points_per_game'),
|
83
87
|
db.Index(f'idx_{cls.aggregation_type}_assists_per_game3', cls.get_aggregation_column(), 'assists_per_game'),
|
84
88
|
db.Index(f'idx_{cls.aggregation_type}_penalties_per_game3', cls.get_aggregation_column(), 'penalties_per_game'),
|
89
|
+
db.Index(f'idx_{cls.aggregation_type}_gm_penalties_per_game3', cls.get_aggregation_column(), 'gm_penalties_per_game'),
|
85
90
|
db.Index(f'idx_{cls.aggregation_type}_games_played3', cls.get_aggregation_column(), 'games_played')
|
86
91
|
)
|
87
92
|
|
{hockey_blast_common_lib-0.1.39.dist-info → hockey_blast_common_lib-0.1.41.dist-info}/RECORD
RENAMED
@@ -1,23 +1,23 @@
|
|
1
1
|
hockey_blast_common_lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
hockey_blast_common_lib/aggregate_all_stats.py,sha256=MUjT23mdOMfCTx-kRSY-LGrLHZ9HNlR6OMqv5KLdzR4,1056
|
3
|
-
hockey_blast_common_lib/aggregate_goalie_stats.py,sha256=
|
4
|
-
hockey_blast_common_lib/aggregate_human_stats.py,sha256=
|
5
|
-
hockey_blast_common_lib/aggregate_referee_stats.py,sha256=
|
6
|
-
hockey_blast_common_lib/aggregate_skater_stats.py,sha256=
|
3
|
+
hockey_blast_common_lib/aggregate_goalie_stats.py,sha256=FcYL40NP0-sPY7UI7F8Ny_RaPKz3mfkmhQnPVbeRtOc,12178
|
4
|
+
hockey_blast_common_lib/aggregate_human_stats.py,sha256=6cDoiJ0xZ3aQ4wjEAP_Jgu2aNEicnuU-a22BncSFtRo,23920
|
5
|
+
hockey_blast_common_lib/aggregate_referee_stats.py,sha256=FszWLTygddDQNcUgbmevQ-eGPrW8Y0nXpRvUluPRKnU,11920
|
6
|
+
hockey_blast_common_lib/aggregate_skater_stats.py,sha256=FBc6enJNnFXYg7mVPiXssleTA1vZRAXCTFUa-3eOGdo,17199
|
7
7
|
hockey_blast_common_lib/assign_skater_skill.py,sha256=p-0fbodGpM8BCjKHDpxNb7BH2FcIlBsJwON844KNrUY,1817
|
8
8
|
hockey_blast_common_lib/db_connection.py,sha256=HvPxDvOj7j5H85RfslGvHVNevfg7mKCd0syJ6NX21mU,1890
|
9
9
|
hockey_blast_common_lib/dump_sample_db.sh,sha256=MHPA-Ciod7wsvAlMbRtXFiyajgnEqU1xR59sJQ9UWR0,738
|
10
|
-
hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz,sha256=
|
10
|
+
hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz,sha256=TWtisyYlIRkQCKfyXRS_iYKq_8qDb6KHQEg020FkKrM,51
|
11
11
|
hockey_blast_common_lib/models.py,sha256=xne38KwdBDcWvzdLyU6toozqkuatB9wiQhyiQ4xvAgU,16413
|
12
12
|
hockey_blast_common_lib/options.py,sha256=6na8fo-5A2RBPpd_h-7dsqetOLSLoNEJg1QMYgl4jNs,792
|
13
13
|
hockey_blast_common_lib/restore_sample_db.sh,sha256=u2zKazC6vNMULkpYzI64nlneCWaGUtDHPBAU-gWgRbw,1861
|
14
14
|
hockey_blast_common_lib/skills_in_divisions.py,sha256=m-UEwMwn1KM7wOYvDstgsOEeH57M9V6yrkBoghzGYKE,7005
|
15
15
|
hockey_blast_common_lib/skills_propagation.py,sha256=x6yy7fJ6IX3YiHqiP_v7-p_S2Expb8JJ-mWuajEFBdY,16388
|
16
|
-
hockey_blast_common_lib/stats_models.py,sha256=
|
16
|
+
hockey_blast_common_lib/stats_models.py,sha256=NWigeIowIJU6o1Sk1cP08kEy4t594LZpecKUnl-O6as,25552
|
17
17
|
hockey_blast_common_lib/stats_utils.py,sha256=DXsPO4jw8XsdRUN46TGF_IiBAfz3GCIVBswCGp5ELDk,284
|
18
18
|
hockey_blast_common_lib/utils.py,sha256=Sy5Pk40Tk3gsMrhMsUMlBD7i7jiVZmWLUBc94qI3zOA,5235
|
19
19
|
hockey_blast_common_lib/wsgi.py,sha256=7LGUzioigviJp-EUhSEaQcd4jBae0mxbkyBscQfZhlc,730
|
20
|
-
hockey_blast_common_lib-0.1.
|
21
|
-
hockey_blast_common_lib-0.1.
|
22
|
-
hockey_blast_common_lib-0.1.
|
23
|
-
hockey_blast_common_lib-0.1.
|
20
|
+
hockey_blast_common_lib-0.1.41.dist-info/METADATA,sha256=r0-HHK9qO6fisdLkPOc4pDRMEfobEu4D4sstUM1-gsw,318
|
21
|
+
hockey_blast_common_lib-0.1.41.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
22
|
+
hockey_blast_common_lib-0.1.41.dist-info/top_level.txt,sha256=wIR4LIkE40npoA2QlOdfCYlgFeGbsHR8Z6r0h46Vtgc,24
|
23
|
+
hockey_blast_common_lib-0.1.41.dist-info/RECORD,,
|
File without changes
|
{hockey_blast_common_lib-0.1.39.dist-info → hockey_blast_common_lib-0.1.41.dist-info}/top_level.txt
RENAMED
File without changes
|