hockey-blast-common-lib 0.1.59__py3-none-any.whl → 0.1.61__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 -18
- hockey_blast_common_lib/aggregate_human_stats.py +18 -18
- hockey_blast_common_lib/aggregate_referee_stats.py +18 -18
- hockey_blast_common_lib/aggregate_scorekeeper_stats.py +10 -10
- hockey_blast_common_lib/aggregate_skater_stats.py +18 -18
- hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz +0 -0
- hockey_blast_common_lib/models.py +13 -0
- hockey_blast_common_lib/options.py +0 -11
- hockey_blast_common_lib/utils.py +18 -0
- {hockey_blast_common_lib-0.1.59.dist-info → hockey_blast_common_lib-0.1.61.dist-info}/METADATA +1 -1
- {hockey_blast_common_lib-0.1.59.dist-info → hockey_blast_common_lib-0.1.61.dist-info}/RECORD +13 -13
- {hockey_blast_common_lib-0.1.59.dist-info → hockey_blast_common_lib-0.1.61.dist-info}/WHEEL +0 -0
- {hockey_blast_common_lib-0.1.59.dist-info → hockey_blast_common_lib-0.1.61.dist-info}/top_level.txt +0 -0
@@ -10,14 +10,14 @@ from hockey_blast_common_lib.models import Game, Organization, Division, Human,
|
|
10
10
|
from hockey_blast_common_lib.stats_models import OrgStatsGoalie, DivisionStatsGoalie, OrgStatsWeeklyGoalie, OrgStatsDailyGoalie, DivisionStatsWeeklyGoalie, DivisionStatsDailyGoalie, LevelStatsGoalie
|
11
11
|
from hockey_blast_common_lib.db_connection import create_session
|
12
12
|
from sqlalchemy.sql import func
|
13
|
-
from hockey_blast_common_lib.options import
|
14
|
-
from hockey_blast_common_lib.utils import
|
13
|
+
from hockey_blast_common_lib.options import MIN_GAMES_FOR_ORG_STATS, MIN_GAMES_FOR_DIVISION_STATS, MIN_GAMES_FOR_LEVEL_STATS
|
14
|
+
from hockey_blast_common_lib.utils import get_non_human_ids, get_all_division_ids_for_org, get_start_datetime
|
15
15
|
from hockey_blast_common_lib.utils import assign_ranks
|
16
16
|
from hockey_blast_common_lib.stats_utils import ALL_ORGS_ID
|
17
17
|
from hockey_blast_common_lib.progress_utils import create_progress_tracker
|
18
18
|
|
19
|
-
def aggregate_goalie_stats(session, aggregation_type, aggregation_id,
|
20
|
-
human_ids_to_filter =
|
19
|
+
def aggregate_goalie_stats(session, aggregation_type, aggregation_id, debug_human_id=None, aggregation_window=None):
|
20
|
+
human_ids_to_filter = get_non_human_ids(session)
|
21
21
|
|
22
22
|
# Get the name of the aggregation, for debug purposes
|
23
23
|
if aggregation_type == 'org':
|
@@ -195,30 +195,30 @@ def run_aggregate_goalie_stats():
|
|
195
195
|
# Process divisions with progress tracking
|
196
196
|
progress = create_progress_tracker(len(division_ids), f"Processing {len(division_ids)} divisions for {org_name}")
|
197
197
|
for i, division_id in enumerate(division_ids):
|
198
|
-
aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id,
|
199
|
-
aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id,
|
200
|
-
aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id,
|
198
|
+
aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id, debug_human_id=human_id_to_debug)
|
199
|
+
aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
|
200
|
+
aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id, debug_human_id=human_id_to_debug, aggregation_window='Daily')
|
201
201
|
progress.update(i + 1)
|
202
202
|
else:
|
203
203
|
# Debug mode or no divisions - process without progress tracking
|
204
204
|
for division_id in division_ids:
|
205
|
-
aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id,
|
206
|
-
aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id,
|
207
|
-
aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id,
|
205
|
+
aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id, debug_human_id=human_id_to_debug)
|
206
|
+
aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
|
207
|
+
aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id, debug_human_id=human_id_to_debug, aggregation_window='Daily')
|
208
208
|
|
209
209
|
# Process org-level stats with progress tracking
|
210
210
|
if human_id_to_debug is None:
|
211
211
|
org_progress = create_progress_tracker(3, f"Processing org-level stats for {org_name}")
|
212
|
-
aggregate_goalie_stats(session, aggregation_type='org', aggregation_id=org_id,
|
212
|
+
aggregate_goalie_stats(session, aggregation_type='org', aggregation_id=org_id, debug_human_id=human_id_to_debug)
|
213
213
|
org_progress.update(1)
|
214
|
-
aggregate_goalie_stats(session, aggregation_type='org', aggregation_id=org_id,
|
214
|
+
aggregate_goalie_stats(session, aggregation_type='org', aggregation_id=org_id, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
|
215
215
|
org_progress.update(2)
|
216
|
-
aggregate_goalie_stats(session, aggregation_type='org', aggregation_id=org_id,
|
216
|
+
aggregate_goalie_stats(session, aggregation_type='org', aggregation_id=org_id, debug_human_id=human_id_to_debug, aggregation_window='Daily')
|
217
217
|
org_progress.update(3)
|
218
218
|
else:
|
219
|
-
aggregate_goalie_stats(session, aggregation_type='org', aggregation_id=org_id,
|
220
|
-
aggregate_goalie_stats(session, aggregation_type='org', aggregation_id=org_id,
|
221
|
-
aggregate_goalie_stats(session, aggregation_type='org', aggregation_id=org_id,
|
219
|
+
aggregate_goalie_stats(session, aggregation_type='org', aggregation_id=org_id, debug_human_id=human_id_to_debug)
|
220
|
+
aggregate_goalie_stats(session, aggregation_type='org', aggregation_id=org_id, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
|
221
|
+
aggregate_goalie_stats(session, aggregation_type='org', aggregation_id=org_id, debug_human_id=human_id_to_debug, aggregation_window='Daily')
|
222
222
|
|
223
223
|
# Aggregate by level
|
224
224
|
level_ids = session.query(Division.level_id).distinct().all()
|
@@ -228,12 +228,12 @@ def run_aggregate_goalie_stats():
|
|
228
228
|
# Process levels with progress tracking
|
229
229
|
level_progress = create_progress_tracker(len(level_ids), f"Processing {len(level_ids)} skill levels")
|
230
230
|
for i, level_id in enumerate(level_ids):
|
231
|
-
aggregate_goalie_stats(session, aggregation_type='level', aggregation_id=level_id,
|
231
|
+
aggregate_goalie_stats(session, aggregation_type='level', aggregation_id=level_id, debug_human_id=human_id_to_debug)
|
232
232
|
level_progress.update(i + 1)
|
233
233
|
else:
|
234
234
|
# Debug mode or no levels - process without progress tracking
|
235
235
|
for level_id in level_ids:
|
236
|
-
aggregate_goalie_stats(session, aggregation_type='level', aggregation_id=level_id,
|
236
|
+
aggregate_goalie_stats(session, aggregation_type='level', aggregation_id=level_id, debug_human_id=human_id_to_debug)
|
237
237
|
|
238
238
|
if __name__ == "__main__":
|
239
239
|
run_aggregate_goalie_stats()
|
@@ -10,15 +10,15 @@ from hockey_blast_common_lib.models import Game, GameRoster, Organization, Divis
|
|
10
10
|
from hockey_blast_common_lib.stats_models import OrgStatsHuman, DivisionStatsHuman, OrgStatsDailyHuman, OrgStatsWeeklyHuman, DivisionStatsDailyHuman, DivisionStatsWeeklyHuman, LevelStatsHuman
|
11
11
|
from hockey_blast_common_lib.db_connection import create_session
|
12
12
|
from sqlalchemy.sql import func, case
|
13
|
-
from hockey_blast_common_lib.options import parse_args, MIN_GAMES_FOR_ORG_STATS, MIN_GAMES_FOR_DIVISION_STATS, MIN_GAMES_FOR_LEVEL_STATS
|
14
|
-
from hockey_blast_common_lib.utils import get_fake_human_for_stats, get_org_id_from_alias,
|
13
|
+
from hockey_blast_common_lib.options import parse_args, MIN_GAMES_FOR_ORG_STATS, MIN_GAMES_FOR_DIVISION_STATS, MIN_GAMES_FOR_LEVEL_STATS
|
14
|
+
from hockey_blast_common_lib.utils import get_fake_human_for_stats, get_org_id_from_alias, get_non_human_ids, get_division_ids_for_last_season_in_all_leagues, get_all_division_ids_for_org
|
15
15
|
from hockey_blast_common_lib.utils import assign_ranks
|
16
16
|
from hockey_blast_common_lib.utils import get_start_datetime
|
17
17
|
from hockey_blast_common_lib.stats_utils import ALL_ORGS_ID
|
18
18
|
from hockey_blast_common_lib.progress_utils import create_progress_tracker
|
19
19
|
|
20
|
-
def aggregate_human_stats(session, aggregation_type, aggregation_id,
|
21
|
-
human_ids_to_filter =
|
20
|
+
def aggregate_human_stats(session, aggregation_type, aggregation_id, human_id_filter=None, aggregation_window=None):
|
21
|
+
human_ids_to_filter = get_non_human_ids(session)
|
22
22
|
|
23
23
|
if aggregation_type == 'org':
|
24
24
|
if aggregation_id == ALL_ORGS_ID:
|
@@ -434,30 +434,30 @@ def run_aggregate_human_stats():
|
|
434
434
|
# Process divisions with progress tracking
|
435
435
|
progress = create_progress_tracker(len(division_ids), f"Processing {len(division_ids)} divisions for {org_name}")
|
436
436
|
for i, division_id in enumerate(division_ids):
|
437
|
-
aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id,
|
438
|
-
aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id,
|
439
|
-
aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id,
|
437
|
+
aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id, human_id_filter=human_id_to_debug)
|
438
|
+
aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id, human_id_filter=human_id_to_debug, aggregation_window='Weekly')
|
439
|
+
aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id, human_id_filter=human_id_to_debug, aggregation_window='Daily')
|
440
440
|
progress.update(i + 1)
|
441
441
|
else:
|
442
442
|
# Debug mode or no divisions - process without progress tracking
|
443
443
|
for division_id in division_ids:
|
444
|
-
aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id,
|
445
|
-
aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id,
|
446
|
-
aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id,
|
444
|
+
aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id, human_id_filter=human_id_to_debug)
|
445
|
+
aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id, human_id_filter=human_id_to_debug, aggregation_window='Weekly')
|
446
|
+
aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id, human_id_filter=human_id_to_debug, aggregation_window='Daily')
|
447
447
|
|
448
448
|
# Process org-level stats with progress tracking
|
449
449
|
if human_id_to_debug is None:
|
450
450
|
org_progress = create_progress_tracker(3, f"Processing org-level stats for {org_name}")
|
451
|
-
aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id,
|
451
|
+
aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id, human_id_filter=human_id_to_debug)
|
452
452
|
org_progress.update(1)
|
453
|
-
aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id,
|
453
|
+
aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id, human_id_filter=human_id_to_debug, aggregation_window='Weekly')
|
454
454
|
org_progress.update(2)
|
455
|
-
aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id,
|
455
|
+
aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id, human_id_filter=human_id_to_debug, aggregation_window='Daily')
|
456
456
|
org_progress.update(3)
|
457
457
|
else:
|
458
|
-
aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id,
|
459
|
-
aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id,
|
460
|
-
aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id,
|
458
|
+
aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id, human_id_filter=human_id_to_debug)
|
459
|
+
aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id, human_id_filter=human_id_to_debug, aggregation_window='Weekly')
|
460
|
+
aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id, human_id_filter=human_id_to_debug, aggregation_window='Daily')
|
461
461
|
|
462
462
|
# Aggregate by level
|
463
463
|
level_ids = session.query(Division.level_id).distinct().all()
|
@@ -467,12 +467,12 @@ def run_aggregate_human_stats():
|
|
467
467
|
# Process levels with progress tracking
|
468
468
|
level_progress = create_progress_tracker(len(level_ids), f"Processing {len(level_ids)} skill levels")
|
469
469
|
for i, level_id in enumerate(level_ids):
|
470
|
-
aggregate_human_stats(session, aggregation_type='level', aggregation_id=level_id,
|
470
|
+
aggregate_human_stats(session, aggregation_type='level', aggregation_id=level_id, human_id_filter=human_id_to_debug)
|
471
471
|
level_progress.update(i + 1)
|
472
472
|
else:
|
473
473
|
# Debug mode or no levels - process without progress tracking
|
474
474
|
for level_id in level_ids:
|
475
|
-
aggregate_human_stats(session, aggregation_type='level', aggregation_id=level_id,
|
475
|
+
aggregate_human_stats(session, aggregation_type='level', aggregation_id=level_id, human_id_filter=human_id_to_debug)
|
476
476
|
|
477
477
|
if __name__ == "__main__":
|
478
478
|
run_aggregate_human_stats()
|
@@ -10,15 +10,15 @@ from hockey_blast_common_lib.models import Game, Penalty, Organization, Division
|
|
10
10
|
from hockey_blast_common_lib.stats_models import OrgStatsReferee, DivisionStatsReferee, OrgStatsWeeklyReferee, OrgStatsDailyReferee, DivisionStatsWeeklyReferee, DivisionStatsDailyReferee, LevelStatsReferee
|
11
11
|
from hockey_blast_common_lib.db_connection import create_session
|
12
12
|
from sqlalchemy.sql import func, case
|
13
|
-
from hockey_blast_common_lib.options import parse_args, MIN_GAMES_FOR_ORG_STATS, MIN_GAMES_FOR_DIVISION_STATS, MIN_GAMES_FOR_LEVEL_STATS
|
14
|
-
from hockey_blast_common_lib.utils import get_org_id_from_alias,
|
13
|
+
from hockey_blast_common_lib.options import parse_args, MIN_GAMES_FOR_ORG_STATS, MIN_GAMES_FOR_DIVISION_STATS, MIN_GAMES_FOR_LEVEL_STATS
|
14
|
+
from hockey_blast_common_lib.utils import get_org_id_from_alias, get_non_human_ids, get_division_ids_for_last_season_in_all_leagues, get_all_division_ids_for_org
|
15
15
|
from hockey_blast_common_lib.utils import assign_ranks
|
16
16
|
from hockey_blast_common_lib.utils import get_start_datetime
|
17
17
|
from hockey_blast_common_lib.stats_utils import ALL_ORGS_ID
|
18
18
|
from hockey_blast_common_lib.progress_utils import create_progress_tracker
|
19
19
|
|
20
|
-
def aggregate_referee_stats(session, aggregation_type, aggregation_id,
|
21
|
-
human_ids_to_filter =
|
20
|
+
def aggregate_referee_stats(session, aggregation_type, aggregation_id, aggregation_window=None):
|
21
|
+
human_ids_to_filter = get_non_human_ids(session)
|
22
22
|
|
23
23
|
if aggregation_type == 'org':
|
24
24
|
if aggregation_id == ALL_ORGS_ID:
|
@@ -221,30 +221,30 @@ def run_aggregate_referee_stats():
|
|
221
221
|
# Process divisions with progress tracking
|
222
222
|
progress = create_progress_tracker(len(division_ids), f"Processing {len(division_ids)} divisions for {org_name}")
|
223
223
|
for i, division_id in enumerate(division_ids):
|
224
|
-
aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id
|
225
|
-
aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id,
|
226
|
-
aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id,
|
224
|
+
aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id)
|
225
|
+
aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id, aggregation_window='Weekly')
|
226
|
+
aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id, aggregation_window='Daily')
|
227
227
|
progress.update(i + 1)
|
228
228
|
else:
|
229
229
|
# Debug mode or no divisions - process without progress tracking
|
230
230
|
for division_id in division_ids:
|
231
|
-
aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id
|
232
|
-
aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id,
|
233
|
-
aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id,
|
231
|
+
aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id)
|
232
|
+
aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id, aggregation_window='Weekly')
|
233
|
+
aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id, aggregation_window='Daily')
|
234
234
|
|
235
235
|
# Process org-level stats with progress tracking
|
236
236
|
if human_id_to_debug is None:
|
237
237
|
org_progress = create_progress_tracker(3, f"Processing org-level stats for {org_name}")
|
238
|
-
aggregate_referee_stats(session, aggregation_type='org', aggregation_id=org_id
|
238
|
+
aggregate_referee_stats(session, aggregation_type='org', aggregation_id=org_id)
|
239
239
|
org_progress.update(1)
|
240
|
-
aggregate_referee_stats(session, aggregation_type='org', aggregation_id=org_id,
|
240
|
+
aggregate_referee_stats(session, aggregation_type='org', aggregation_id=org_id, aggregation_window='Weekly')
|
241
241
|
org_progress.update(2)
|
242
|
-
aggregate_referee_stats(session, aggregation_type='org', aggregation_id=org_id,
|
242
|
+
aggregate_referee_stats(session, aggregation_type='org', aggregation_id=org_id, aggregation_window='Daily')
|
243
243
|
org_progress.update(3)
|
244
244
|
else:
|
245
|
-
aggregate_referee_stats(session, aggregation_type='org', aggregation_id=org_id
|
246
|
-
aggregate_referee_stats(session, aggregation_type='org', aggregation_id=org_id,
|
247
|
-
aggregate_referee_stats(session, aggregation_type='org', aggregation_id=org_id,
|
245
|
+
aggregate_referee_stats(session, aggregation_type='org', aggregation_id=org_id)
|
246
|
+
aggregate_referee_stats(session, aggregation_type='org', aggregation_id=org_id, aggregation_window='Weekly')
|
247
|
+
aggregate_referee_stats(session, aggregation_type='org', aggregation_id=org_id, aggregation_window='Daily')
|
248
248
|
|
249
249
|
# Aggregate by level
|
250
250
|
level_ids = session.query(Division.level_id).distinct().all()
|
@@ -254,12 +254,12 @@ def run_aggregate_referee_stats():
|
|
254
254
|
# Process levels with progress tracking
|
255
255
|
level_progress = create_progress_tracker(len(level_ids), f"Processing {len(level_ids)} skill levels")
|
256
256
|
for i, level_id in enumerate(level_ids):
|
257
|
-
aggregate_referee_stats(session, aggregation_type='level', aggregation_id=level_id
|
257
|
+
aggregate_referee_stats(session, aggregation_type='level', aggregation_id=level_id)
|
258
258
|
level_progress.update(i + 1)
|
259
259
|
else:
|
260
260
|
# Debug mode or no levels - process without progress tracking
|
261
261
|
for level_id in level_ids:
|
262
|
-
aggregate_referee_stats(session, aggregation_type='level', aggregation_id=level_id
|
262
|
+
aggregate_referee_stats(session, aggregation_type='level', aggregation_id=level_id)
|
263
263
|
|
264
264
|
if __name__ == "__main__":
|
265
265
|
run_aggregate_referee_stats()
|
@@ -10,8 +10,8 @@ from hockey_blast_common_lib.models import Game, ScorekeeperSaveQuality
|
|
10
10
|
from hockey_blast_common_lib.stats_models import OrgStatsScorekeeper, OrgStatsWeeklyScorekeeper, OrgStatsDailyScorekeeper
|
11
11
|
from hockey_blast_common_lib.db_connection import create_session
|
12
12
|
from sqlalchemy.sql import func, case
|
13
|
-
from hockey_blast_common_lib.options import parse_args, MIN_GAMES_FOR_ORG_STATS, MIN_GAMES_FOR_DIVISION_STATS
|
14
|
-
from hockey_blast_common_lib.utils import get_org_id_from_alias,
|
13
|
+
from hockey_blast_common_lib.options import parse_args, MIN_GAMES_FOR_ORG_STATS, MIN_GAMES_FOR_DIVISION_STATS
|
14
|
+
from hockey_blast_common_lib.utils import get_org_id_from_alias, get_non_human_ids
|
15
15
|
from hockey_blast_common_lib.utils import assign_ranks
|
16
16
|
from hockey_blast_common_lib.utils import get_start_datetime
|
17
17
|
from hockey_blast_common_lib.stats_utils import ALL_ORGS_ID
|
@@ -51,13 +51,13 @@ def calculate_quality_score(avg_max_saves_5sec, avg_max_saves_20sec, peak_max_sa
|
|
51
51
|
|
52
52
|
return round(score, 2)
|
53
53
|
|
54
|
-
def aggregate_scorekeeper_stats(session, aggregation_type, aggregation_id,
|
54
|
+
def aggregate_scorekeeper_stats(session, aggregation_type, aggregation_id, aggregation_window=None):
|
55
55
|
# Only process scorekeeper stats for ALL_ORGS_ID - skip individual organizations
|
56
56
|
# This prevents redundant processing when upstream logic calls with all organization IDs
|
57
57
|
if aggregation_type == 'org' and aggregation_id != ALL_ORGS_ID:
|
58
58
|
return # Do nothing for individual organization IDs
|
59
59
|
|
60
|
-
human_ids_to_filter =
|
60
|
+
human_ids_to_filter = get_non_human_ids(session)
|
61
61
|
|
62
62
|
if aggregation_type == 'org':
|
63
63
|
aggregation_name = "All Orgs"
|
@@ -216,16 +216,16 @@ def run_aggregate_scorekeeper_stats():
|
|
216
216
|
if human_id_to_debug is None:
|
217
217
|
org_name = "All Organizations" if org_id == ALL_ORGS_ID else session.query(Organization.organization_name).filter(Organization.id == org_id).scalar() or f"org_id {org_id}"
|
218
218
|
org_progress = create_progress_tracker(3, f"Processing scorekeeper stats for {org_name}")
|
219
|
-
aggregate_scorekeeper_stats(session, aggregation_type='org', aggregation_id=org_id
|
219
|
+
aggregate_scorekeeper_stats(session, aggregation_type='org', aggregation_id=org_id)
|
220
220
|
org_progress.update(1)
|
221
|
-
aggregate_scorekeeper_stats(session, aggregation_type='org', aggregation_id=org_id,
|
221
|
+
aggregate_scorekeeper_stats(session, aggregation_type='org', aggregation_id=org_id, aggregation_window='Weekly')
|
222
222
|
org_progress.update(2)
|
223
|
-
aggregate_scorekeeper_stats(session, aggregation_type='org', aggregation_id=org_id,
|
223
|
+
aggregate_scorekeeper_stats(session, aggregation_type='org', aggregation_id=org_id, aggregation_window='Daily')
|
224
224
|
org_progress.update(3)
|
225
225
|
else:
|
226
|
-
aggregate_scorekeeper_stats(session, aggregation_type='org', aggregation_id=org_id
|
227
|
-
aggregate_scorekeeper_stats(session, aggregation_type='org', aggregation_id=org_id,
|
228
|
-
aggregate_scorekeeper_stats(session, aggregation_type='org', aggregation_id=org_id,
|
226
|
+
aggregate_scorekeeper_stats(session, aggregation_type='org', aggregation_id=org_id)
|
227
|
+
aggregate_scorekeeper_stats(session, aggregation_type='org', aggregation_id=org_id, aggregation_window='Weekly')
|
228
|
+
aggregate_scorekeeper_stats(session, aggregation_type='org', aggregation_id=org_id, aggregation_window='Daily')
|
229
229
|
|
230
230
|
if __name__ == "__main__":
|
231
231
|
run_aggregate_scorekeeper_stats()
|
@@ -10,8 +10,8 @@ from hockey_blast_common_lib.models import Game, Goal, Penalty, GameRoster, Orga
|
|
10
10
|
from hockey_blast_common_lib.stats_models import OrgStatsSkater, DivisionStatsSkater, OrgStatsWeeklySkater, OrgStatsDailySkater, DivisionStatsWeeklySkater, DivisionStatsDailySkater, LevelStatsSkater
|
11
11
|
from hockey_blast_common_lib.db_connection import create_session
|
12
12
|
from sqlalchemy.sql import func, case
|
13
|
-
from hockey_blast_common_lib.options import
|
14
|
-
from hockey_blast_common_lib.utils import get_org_id_from_alias,
|
13
|
+
from hockey_blast_common_lib.options import parse_args, MIN_GAMES_FOR_ORG_STATS, MIN_GAMES_FOR_DIVISION_STATS, MIN_GAMES_FOR_LEVEL_STATS
|
14
|
+
from hockey_blast_common_lib.utils import get_org_id_from_alias, get_non_human_ids, get_division_ids_for_last_season_in_all_leagues, get_all_division_ids_for_org
|
15
15
|
from hockey_blast_common_lib.utils import get_start_datetime
|
16
16
|
from sqlalchemy import func, case, and_
|
17
17
|
from collections import defaultdict
|
@@ -64,8 +64,8 @@ def calculate_current_point_streak(session, human_id, filter_condition):
|
|
64
64
|
|
65
65
|
return current_streak, avg_points_during_streak
|
66
66
|
|
67
|
-
def aggregate_skater_stats(session, aggregation_type, aggregation_id,
|
68
|
-
human_ids_to_filter =
|
67
|
+
def aggregate_skater_stats(session, aggregation_type, aggregation_id, debug_human_id=None, aggregation_window=None):
|
68
|
+
human_ids_to_filter = get_non_human_ids(session)
|
69
69
|
|
70
70
|
# Get the name of the aggregation, for debug purposes
|
71
71
|
if aggregation_type == 'org':
|
@@ -382,30 +382,30 @@ def run_aggregate_skater_stats():
|
|
382
382
|
# Process divisions with progress tracking
|
383
383
|
progress = create_progress_tracker(len(division_ids), f"Processing {len(division_ids)} divisions for {org_name}")
|
384
384
|
for i, division_id in enumerate(division_ids):
|
385
|
-
aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id,
|
386
|
-
aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id,
|
387
|
-
aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id,
|
385
|
+
aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id, debug_human_id=human_id_to_debug)
|
386
|
+
aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
|
387
|
+
aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id, debug_human_id=human_id_to_debug, aggregation_window='Daily')
|
388
388
|
progress.update(i + 1)
|
389
389
|
else:
|
390
390
|
# Debug mode or no divisions - process without progress tracking
|
391
391
|
for division_id in division_ids:
|
392
|
-
aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id,
|
393
|
-
aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id,
|
394
|
-
aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id,
|
392
|
+
aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id, debug_human_id=human_id_to_debug)
|
393
|
+
aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
|
394
|
+
aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id, debug_human_id=human_id_to_debug, aggregation_window='Daily')
|
395
395
|
|
396
396
|
# Process org-level stats with progress tracking
|
397
397
|
if human_id_to_debug is None:
|
398
398
|
org_progress = create_progress_tracker(3, f"Processing org-level stats for {org_name}")
|
399
|
-
aggregate_skater_stats(session, aggregation_type='org', aggregation_id=org_id,
|
399
|
+
aggregate_skater_stats(session, aggregation_type='org', aggregation_id=org_id, debug_human_id=human_id_to_debug)
|
400
400
|
org_progress.update(1)
|
401
|
-
aggregate_skater_stats(session, aggregation_type='org', aggregation_id=org_id,
|
401
|
+
aggregate_skater_stats(session, aggregation_type='org', aggregation_id=org_id, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
|
402
402
|
org_progress.update(2)
|
403
|
-
aggregate_skater_stats(session, aggregation_type='org', aggregation_id=org_id,
|
403
|
+
aggregate_skater_stats(session, aggregation_type='org', aggregation_id=org_id, debug_human_id=human_id_to_debug, aggregation_window='Daily')
|
404
404
|
org_progress.update(3)
|
405
405
|
else:
|
406
|
-
aggregate_skater_stats(session, aggregation_type='org', aggregation_id=org_id,
|
407
|
-
aggregate_skater_stats(session, aggregation_type='org', aggregation_id=org_id,
|
408
|
-
aggregate_skater_stats(session, aggregation_type='org', aggregation_id=org_id,
|
406
|
+
aggregate_skater_stats(session, aggregation_type='org', aggregation_id=org_id, debug_human_id=human_id_to_debug)
|
407
|
+
aggregate_skater_stats(session, aggregation_type='org', aggregation_id=org_id, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
|
408
|
+
aggregate_skater_stats(session, aggregation_type='org', aggregation_id=org_id, debug_human_id=human_id_to_debug, aggregation_window='Daily')
|
409
409
|
|
410
410
|
# Aggregate by level
|
411
411
|
level_ids = session.query(Division.level_id).distinct().all()
|
@@ -415,12 +415,12 @@ def run_aggregate_skater_stats():
|
|
415
415
|
# Process levels with progress tracking
|
416
416
|
level_progress = create_progress_tracker(len(level_ids), f"Processing {len(level_ids)} skill levels")
|
417
417
|
for i, level_id in enumerate(level_ids):
|
418
|
-
aggregate_skater_stats(session, aggregation_type='level', aggregation_id=level_id,
|
418
|
+
aggregate_skater_stats(session, aggregation_type='level', aggregation_id=level_id, debug_human_id=human_id_to_debug)
|
419
419
|
level_progress.update(i + 1)
|
420
420
|
else:
|
421
421
|
# Debug mode or no levels - process without progress tracking
|
422
422
|
for level_id in level_ids:
|
423
|
-
aggregate_skater_stats(session, aggregation_type='level', aggregation_id=level_id,
|
423
|
+
aggregate_skater_stats(session, aggregation_type='level', aggregation_id=level_id, debug_human_id=human_id_to_debug)
|
424
424
|
|
425
425
|
if __name__ == "__main__":
|
426
426
|
run_aggregate_skater_stats()
|
Binary file
|
@@ -152,6 +152,19 @@ class HumansInLevels(db.Model):
|
|
152
152
|
db.UniqueConstraint('levels_monthly_id', 'human_id', name='_levels_monthly_human_uc'),
|
153
153
|
)
|
154
154
|
|
155
|
+
class HumanPrivacyOptOut(db.Model):
|
156
|
+
__tablename__ = 'human_privacy_opt_outs'
|
157
|
+
id = db.Column(db.Integer, primary_key=True)
|
158
|
+
first_name = db.Column(db.String(100), nullable=False)
|
159
|
+
middle_name = db.Column(db.String(100), nullable=False, default='')
|
160
|
+
last_name = db.Column(db.String(100), nullable=False)
|
161
|
+
suffix = db.Column(db.String(100), nullable=False, default='')
|
162
|
+
opt_out_date = db.Column(db.DateTime, nullable=False, default=db.func.current_timestamp())
|
163
|
+
notes = db.Column(db.Text, nullable=True)
|
164
|
+
__table_args__ = (
|
165
|
+
db.UniqueConstraint('first_name', 'middle_name', 'last_name', 'suffix', name='_privacy_optout_name_uc'),
|
166
|
+
)
|
167
|
+
|
155
168
|
class League(db.Model):
|
156
169
|
__tablename__ = 'leagues'
|
157
170
|
id = db.Column(db.Integer, primary_key=True)
|
@@ -9,17 +9,6 @@ MIN_GAMES_FOR_LEVEL_STATS = 1
|
|
9
9
|
|
10
10
|
orgs = {'caha', 'sharksice', 'tvice'}
|
11
11
|
|
12
|
-
not_human_names = [
|
13
|
-
("Home", None, None),
|
14
|
-
("Away", None, None),
|
15
|
-
(None, "Unknown", None),
|
16
|
-
("Not", None , None),
|
17
|
-
(None , None, "Goalie"),
|
18
|
-
("Unassigned",None , None),
|
19
|
-
# Critical addition - primary cause of 93.4% of roster insertion errors
|
20
|
-
("Not", "Signed", "In")
|
21
|
-
]
|
22
|
-
|
23
12
|
def parse_args():
|
24
13
|
parser = argparse.ArgumentParser(description="Process data for a specific organization.")
|
25
14
|
parser.add_argument("org", choices=orgs, help="The organization to process (e.g., 'caha', 'sharksice', 'tvice').")
|
hockey_blast_common_lib/utils.py
CHANGED
@@ -52,6 +52,24 @@ def get_human_ids_by_names(session, names):
|
|
52
52
|
human_ids.update([result.id for result in results])
|
53
53
|
return human_ids
|
54
54
|
|
55
|
+
def get_non_human_ids(session):
|
56
|
+
"""Get IDs of non-human entities (placeholder names, test accounts, etc.)
|
57
|
+
|
58
|
+
Returns set of human_ids that should be filtered out from statistics.
|
59
|
+
Filters out placeholder names like "Home", "Away", "Unknown", etc.
|
60
|
+
"""
|
61
|
+
not_human_names = [
|
62
|
+
("Home", None, None),
|
63
|
+
("Away", None, None),
|
64
|
+
(None, "Unknown", None),
|
65
|
+
("Not", None, None),
|
66
|
+
(None, None, "Goalie"),
|
67
|
+
("Unassigned", None, None),
|
68
|
+
("Not", "Signed", "In"),
|
69
|
+
("Incognito", None, None)
|
70
|
+
]
|
71
|
+
return get_human_ids_by_names(session, not_human_names)
|
72
|
+
|
55
73
|
def get_division_ids_for_last_season_in_all_leagues(session, org_id):
|
56
74
|
# # TODO = remove tmp hack
|
57
75
|
# return get_all_division_ids_for_org(session, org_id)
|
{hockey_blast_common_lib-0.1.59.dist-info → hockey_blast_common_lib-0.1.61.dist-info}/RECORD
RENAMED
@@ -1,28 +1,28 @@
|
|
1
1
|
hockey_blast_common_lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
hockey_blast_common_lib/aggregate_all_stats.py,sha256=QhuSvGjuk4jVywNRcgxB-9ooJAoAbZRkaLjLe9Q1hEM,1363
|
3
|
-
hockey_blast_common_lib/aggregate_goalie_stats.py,sha256=
|
3
|
+
hockey_blast_common_lib/aggregate_goalie_stats.py,sha256=WmKqGdM0SZLYXailCsBM4Wdpy8kOcmPtF9JOxLxzmRc,13217
|
4
4
|
hockey_blast_common_lib/aggregate_h2h_stats.py,sha256=dC5TcJZGkpIQTiq3z40kOX6EjEhFbGv5EL0P1EClBQ0,11117
|
5
|
-
hockey_blast_common_lib/aggregate_human_stats.py,sha256=
|
6
|
-
hockey_blast_common_lib/aggregate_referee_stats.py,sha256=
|
5
|
+
hockey_blast_common_lib/aggregate_human_stats.py,sha256=JZcXJofF1wmFPcLbalM_GiXrq22eUJO28R_xyypw4rI,25456
|
6
|
+
hockey_blast_common_lib/aggregate_referee_stats.py,sha256=oX9UgD_mvvDJv4Sy1jJemUKWNi3N-1sOjfHNSg4VzOE,13351
|
7
7
|
hockey_blast_common_lib/aggregate_s2s_stats.py,sha256=urYN0Q06twwLO-XWGlSMVAVOTVR_D2AWdmoGsxIYHXE,6737
|
8
|
-
hockey_blast_common_lib/aggregate_scorekeeper_stats.py,sha256=
|
9
|
-
hockey_blast_common_lib/aggregate_skater_stats.py,sha256=
|
8
|
+
hockey_blast_common_lib/aggregate_scorekeeper_stats.py,sha256=_SWt7qqUl31As1pkEJ40YLh9ItXdBuen3RjtSzHGP8U,11997
|
9
|
+
hockey_blast_common_lib/aggregate_skater_stats.py,sha256=Y3zDeyEWuEae-PdnFMz7aGRzP4BnYNTut_zqRgR56yI,22715
|
10
10
|
hockey_blast_common_lib/assign_skater_skill.py,sha256=Asq6iRMPsCMDnvuNSd-M3s4Gee4kDocP9Eznwju_9kA,2749
|
11
11
|
hockey_blast_common_lib/db_connection.py,sha256=HvPxDvOj7j5H85RfslGvHVNevfg7mKCd0syJ6NX21mU,1890
|
12
12
|
hockey_blast_common_lib/dump_sample_db.sh,sha256=MY3lnzTXBoWd76-ZlZr9nWsKMEVgyRsUn-LZ2d1JWZs,810
|
13
13
|
hockey_blast_common_lib/h2h_models.py,sha256=0st4xoJO0U6ONfx3BV03BQvHjZE31e_PqZfphAJMoSU,7968
|
14
|
-
hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz,sha256=
|
15
|
-
hockey_blast_common_lib/models.py,sha256=
|
16
|
-
hockey_blast_common_lib/options.py,sha256=
|
14
|
+
hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz,sha256=vJK83rusOv9VoljFTC03-0leXhGBHa1WV0XvM2ri870,4648906
|
15
|
+
hockey_blast_common_lib/models.py,sha256=ccM886RcSFDiJ3yj2l9OqRi_PwR1L6WU8AsqzgV3_t0,19598
|
16
|
+
hockey_blast_common_lib/options.py,sha256=XecGGlizbul7BnMePrvIqvEq5_w49UoG3Yu9iv961gg,1499
|
17
17
|
hockey_blast_common_lib/progress_utils.py,sha256=H_zRFOsb2qQQpGw56wJghZ1nUe_m6zqGeR9hZ33Y1Uo,3229
|
18
18
|
hockey_blast_common_lib/restore_sample_db.sh,sha256=7W3lzRZeu9zXIu1Bvtnaw8EHc1ulHmFM4mMh86oUQJo,2205
|
19
19
|
hockey_blast_common_lib/skills_in_divisions.py,sha256=m-UEwMwn1KM7wOYvDstgsOEeH57M9V6yrkBoghzGYKE,7005
|
20
20
|
hockey_blast_common_lib/skills_propagation.py,sha256=nUxntyK8M4xWjHpkfze8f0suaBeunxicgDCduGmNJ-A,18468
|
21
21
|
hockey_blast_common_lib/stats_models.py,sha256=64sUq_iWhNXi_b_V_1INuQ1RusKaTASjurkRo5gQOs4,26703
|
22
22
|
hockey_blast_common_lib/stats_utils.py,sha256=DXsPO4jw8XsdRUN46TGF_IiBAfz3GCIVBswCGp5ELDk,284
|
23
|
-
hockey_blast_common_lib/utils.py,sha256=
|
23
|
+
hockey_blast_common_lib/utils.py,sha256=1YJRAj1lhftjIAM2frFi4A4K90kCJaxWlgBQ1-77xZY,6486
|
24
24
|
hockey_blast_common_lib/wsgi.py,sha256=y3NxoJfWjdzX3iP7RGvDEer6zcnPyCanpqSgW1BlXgg,779
|
25
|
-
hockey_blast_common_lib-0.1.
|
26
|
-
hockey_blast_common_lib-0.1.
|
27
|
-
hockey_blast_common_lib-0.1.
|
28
|
-
hockey_blast_common_lib-0.1.
|
25
|
+
hockey_blast_common_lib-0.1.61.dist-info/METADATA,sha256=AtOG9FeESKu9wi75z2Q9cOctyOnmyoNYfu6hkiCFn0c,318
|
26
|
+
hockey_blast_common_lib-0.1.61.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
27
|
+
hockey_blast_common_lib-0.1.61.dist-info/top_level.txt,sha256=wIR4LIkE40npoA2QlOdfCYlgFeGbsHR8Z6r0h46Vtgc,24
|
28
|
+
hockey_blast_common_lib-0.1.61.dist-info/RECORD,,
|
File without changes
|
{hockey_blast_common_lib-0.1.59.dist-info → hockey_blast_common_lib-0.1.61.dist-info}/top_level.txt
RENAMED
File without changes
|