hockey-blast-common-lib 0.1.59__tar.gz → 0.1.61__tar.gz

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 (34) hide show
  1. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/PKG-INFO +1 -1
  2. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/aggregate_goalie_stats.py +18 -18
  3. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/aggregate_human_stats.py +18 -18
  4. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/aggregate_referee_stats.py +18 -18
  5. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/aggregate_scorekeeper_stats.py +10 -10
  6. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/aggregate_skater_stats.py +18 -18
  7. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz +0 -0
  8. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/models.py +13 -0
  9. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/options.py +0 -11
  10. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/utils.py +18 -0
  11. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib.egg-info/PKG-INFO +1 -1
  12. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/setup.py +1 -1
  13. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/MANIFEST.in +0 -0
  14. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/README.md +0 -0
  15. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/__init__.py +0 -0
  16. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/aggregate_all_stats.py +0 -0
  17. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/aggregate_h2h_stats.py +0 -0
  18. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/aggregate_s2s_stats.py +0 -0
  19. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/assign_skater_skill.py +0 -0
  20. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/db_connection.py +0 -0
  21. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/dump_sample_db.sh +0 -0
  22. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/h2h_models.py +0 -0
  23. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/progress_utils.py +0 -0
  24. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/restore_sample_db.sh +0 -0
  25. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/skills_in_divisions.py +0 -0
  26. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/skills_propagation.py +0 -0
  27. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/stats_models.py +0 -0
  28. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/stats_utils.py +0 -0
  29. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib/wsgi.py +0 -0
  30. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib.egg-info/SOURCES.txt +0 -0
  31. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib.egg-info/dependency_links.txt +0 -0
  32. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib.egg-info/requires.txt +0 -0
  33. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/hockey_blast_common_lib.egg-info/top_level.txt +0 -0
  34. {hockey_blast_common_lib-0.1.59 → hockey_blast_common_lib-0.1.61}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hockey-blast-common-lib
3
- Version: 0.1.59
3
+ Version: 0.1.61
4
4
  Summary: Common library for shared functionality and DB models
5
5
  Author: Pavel Kletskov
6
6
  Author-email: kletskov@gmail.com
@@ -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 not_human_names, MIN_GAMES_FOR_ORG_STATS, MIN_GAMES_FOR_DIVISION_STATS, MIN_GAMES_FOR_LEVEL_STATS
14
- from hockey_blast_common_lib.utils import get_human_ids_by_names, get_all_division_ids_for_org, get_start_datetime
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, names_to_filter_out, debug_human_id=None, aggregation_window=None):
20
- human_ids_to_filter = get_human_ids_by_names(session, names_to_filter_out)
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug)
199
- aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
200
- aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Daily')
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug)
206
- aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
207
- aggregate_goalie_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Daily')
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug)
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Daily')
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug)
220
- aggregate_goalie_stats(session, aggregation_type='org', aggregation_id=org_id, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
221
- aggregate_goalie_stats(session, aggregation_type='org', aggregation_id=org_id, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Daily')
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug)
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug)
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, not_human_names
14
- from hockey_blast_common_lib.utils import get_fake_human_for_stats, get_org_id_from_alias, get_human_ids_by_names, get_division_ids_for_last_season_in_all_leagues, get_all_division_ids_for_org
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, names_to_filter_out, human_id_filter=None, aggregation_window=None):
21
- human_ids_to_filter = get_human_ids_by_names(session, names_to_filter_out)
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, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug)
438
- aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug, aggregation_window='Weekly')
439
- aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug, aggregation_window='Daily')
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, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug)
445
- aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug, aggregation_window='Weekly')
446
- aggregate_human_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug, aggregation_window='Daily')
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, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug)
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, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug, aggregation_window='Weekly')
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, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug, aggregation_window='Daily')
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, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug)
459
- aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug, aggregation_window='Weekly')
460
- aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug, aggregation_window='Daily')
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, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug)
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, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug)
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, not_human_names
14
- from hockey_blast_common_lib.utils import get_org_id_from_alias, get_human_ids_by_names, get_division_ids_for_last_season_in_all_leagues, get_all_division_ids_for_org
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, names_to_filter_out, aggregation_window=None):
21
- human_ids_to_filter = get_human_ids_by_names(session, names_to_filter_out)
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, names_to_filter_out=not_human_names)
225
- aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, aggregation_window='Weekly')
226
- aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, aggregation_window='Daily')
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, names_to_filter_out=not_human_names)
232
- aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, aggregation_window='Weekly')
233
- aggregate_referee_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, aggregation_window='Daily')
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, names_to_filter_out=not_human_names)
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, names_to_filter_out=not_human_names, aggregation_window='Weekly')
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, names_to_filter_out=not_human_names, aggregation_window='Daily')
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, names_to_filter_out=not_human_names)
246
- aggregate_referee_stats(session, aggregation_type='org', aggregation_id=org_id, names_to_filter_out=not_human_names, aggregation_window='Weekly')
247
- aggregate_referee_stats(session, aggregation_type='org', aggregation_id=org_id, names_to_filter_out=not_human_names, aggregation_window='Daily')
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, names_to_filter_out=not_human_names)
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, names_to_filter_out=not_human_names)
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, not_human_names
14
- from hockey_blast_common_lib.utils import get_org_id_from_alias, get_human_ids_by_names
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, names_to_filter_out, aggregation_window=None):
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 = get_human_ids_by_names(session, names_to_filter_out)
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, names_to_filter_out=not_human_names)
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, names_to_filter_out=not_human_names, aggregation_window='Weekly')
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, names_to_filter_out=not_human_names, aggregation_window='Daily')
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, names_to_filter_out=not_human_names)
227
- aggregate_scorekeeper_stats(session, aggregation_type='org', aggregation_id=org_id, names_to_filter_out=not_human_names, aggregation_window='Weekly')
228
- aggregate_scorekeeper_stats(session, aggregation_type='org', aggregation_id=org_id, names_to_filter_out=not_human_names, aggregation_window='Daily')
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 not_human_names, 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_human_ids_by_names, get_division_ids_for_last_season_in_all_leagues, get_all_division_ids_for_org
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, names_to_filter_out, debug_human_id=None, aggregation_window=None):
68
- human_ids_to_filter = get_human_ids_by_names(session, names_to_filter_out)
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug)
386
- aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
387
- aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Daily')
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug)
393
- aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
394
- aggregate_skater_stats(session, aggregation_type='division', aggregation_id=division_id, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Daily')
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug)
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Daily')
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug)
407
- aggregate_skater_stats(session, aggregation_type='org', aggregation_id=org_id, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Weekly')
408
- aggregate_skater_stats(session, aggregation_type='org', aggregation_id=org_id, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug, aggregation_window='Daily')
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug)
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, names_to_filter_out=not_human_names, debug_human_id=human_id_to_debug)
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()
@@ -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').")
@@ -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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hockey-blast-common-lib
3
- Version: 0.1.59
3
+ Version: 0.1.61
4
4
  Summary: Common library for shared functionality and DB models
5
5
  Author: Pavel Kletskov
6
6
  Author-email: kletskov@gmail.com
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='hockey-blast-common-lib', # The name of your package
5
- version='0.1.59',
5
+ version='0.1.61',
6
6
  description='Common library for shared functionality and DB models',
7
7
  author='Pavel Kletskov',
8
8
  author_email='kletskov@gmail.com',