hockey-blast-common-lib 0.1.49__tar.gz → 0.1.50__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 (30) hide show
  1. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/PKG-INFO +1 -1
  2. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/aggregate_goalie_stats.py +7 -3
  3. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/aggregate_human_stats.py +7 -4
  4. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/aggregate_referee_stats.py +12 -8
  5. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/aggregate_skater_stats.py +8 -5
  6. hockey_blast_common_lib-0.1.50/hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz +0 -0
  7. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/utils.py +11 -2
  8. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib.egg-info/PKG-INFO +1 -1
  9. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/setup.py +1 -1
  10. hockey_blast_common_lib-0.1.49/hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz +0 -0
  11. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/MANIFEST.in +0 -0
  12. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/README.md +0 -0
  13. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/__init__.py +0 -0
  14. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/aggregate_all_stats.py +0 -0
  15. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/assign_skater_skill.py +0 -0
  16. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/db_connection.py +0 -0
  17. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/dump_sample_db.sh +0 -0
  18. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/models.py +0 -0
  19. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/options.py +0 -0
  20. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/restore_sample_db.sh +0 -0
  21. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/skills_in_divisions.py +0 -0
  22. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/skills_propagation.py +0 -0
  23. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/stats_models.py +0 -0
  24. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/stats_utils.py +0 -0
  25. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib/wsgi.py +0 -0
  26. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib.egg-info/SOURCES.txt +0 -0
  27. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib.egg-info/dependency_links.txt +0 -0
  28. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib.egg-info/requires.txt +0 -0
  29. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/hockey_blast_common_lib.egg-info/top_level.txt +0 -0
  30. {hockey_blast_common_lib-0.1.49 → hockey_blast_common_lib-0.1.50}/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.49
3
+ Version: 0.1.50
4
4
  Summary: Common library for shared functionality and DB models
5
5
  Author: Pavel Kletskov
6
6
  Author-email: kletskov@gmail.com
@@ -56,6 +56,10 @@ def aggregate_goalie_stats(session, aggregation_type, aggregation_id, names_to_f
56
56
  else:
57
57
  raise ValueError("Invalid aggregation type")
58
58
 
59
+ # Delete existing items from the stats table
60
+ session.query(StatsModel).filter(StatsModel.aggregation_id == aggregation_id).delete()
61
+ session.commit()
62
+
59
63
  # Apply aggregation window filter
60
64
  if aggregation_window:
61
65
  last_game_datetime_str = session.query(func.max(func.concat(Game.date, ' ', Game.time))).filter(filter_condition, Game.status.like('Final%')).scalar()
@@ -63,10 +67,10 @@ def aggregate_goalie_stats(session, aggregation_type, aggregation_id, names_to_f
63
67
  if start_datetime:
64
68
  game_window_filter = func.cast(func.concat(Game.date, ' ', Game.time), sqlalchemy.types.TIMESTAMP).between(start_datetime, last_game_datetime_str)
65
69
  filter_condition = filter_condition & game_window_filter
70
+ else:
71
+ #print(f"Warning: No valid start datetime for aggregation window '{aggregation_window}' for {aggregation_name}. No games will be included.")
72
+ return
66
73
 
67
- # Delete existing items from the stats table
68
- session.query(StatsModel).filter(StatsModel.aggregation_id == aggregation_id).delete()
69
- session.commit()
70
74
 
71
75
  # Filter for specific human_id if provided
72
76
  human_filter = []
@@ -54,6 +54,10 @@ def aggregate_human_stats(session, aggregation_type, aggregation_id, names_to_fi
54
54
  else:
55
55
  raise ValueError("Invalid aggregation type")
56
56
 
57
+ # Delete existing items from the stats table
58
+ session.query(StatsModel).filter(StatsModel.aggregation_id == aggregation_id).delete()
59
+ session.commit()
60
+
57
61
  # Apply aggregation window filter
58
62
  if aggregation_window:
59
63
  last_game_datetime_str = session.query(func.max(func.concat(Game.date, ' ', Game.time))).filter(filter_condition, Game.status.like('Final%')).scalar()
@@ -61,10 +65,9 @@ def aggregate_human_stats(session, aggregation_type, aggregation_id, names_to_fi
61
65
  if start_datetime:
62
66
  game_window_filter = func.cast(func.concat(Game.date, ' ', Game.time), sqlalchemy.types.TIMESTAMP).between(start_datetime, last_game_datetime_str)
63
67
  filter_condition = filter_condition & game_window_filter
64
-
65
- # Delete existing items from the stats table
66
- session.query(StatsModel).filter(StatsModel.aggregation_id == aggregation_id).delete()
67
- session.commit()
68
+ else:
69
+ #print(f"Warning: No valid start datetime for aggregation window '{aggregation_window}' for {aggregation_name}. No games will be included.")
70
+ return
68
71
 
69
72
  # Filter for specific human_id if provided
70
73
  human_filter = []
@@ -48,12 +48,16 @@ def aggregate_referee_stats(session, aggregation_type, aggregation_id, names_to_
48
48
  min_games = MIN_GAMES_FOR_LEVEL_STATS
49
49
  filter_condition = Division.level_id == aggregation_id
50
50
  # Add filter to only include games for the last 5 years
51
- five_years_ago = datetime.now() - timedelta(days=5*365)
52
- level_window_filter = func.cast(func.concat(Game.date, ' ', Game.time), sqlalchemy.types.TIMESTAMP) >= five_years_ago
53
- filter_condition = filter_condition & level_window_filter
51
+ # five_years_ago = datetime.now() - timedelta(days=5*365)
52
+ # level_window_filter = func.cast(func.concat(Game.date, ' ', Game.time), sqlalchemy.types.TIMESTAMP) >= five_years_ago
53
+ # filter_condition = filter_condition & level_window_filter
54
54
  else:
55
55
  raise ValueError("Invalid aggregation type")
56
56
 
57
+ # Delete existing items from the stats table
58
+ session.query(StatsModel).filter(StatsModel.aggregation_id == aggregation_id).delete()
59
+ session.commit()
60
+
57
61
  # Apply aggregation window filter
58
62
  if aggregation_window:
59
63
  last_game_datetime_str = session.query(func.max(func.concat(Game.date, ' ', Game.time))).filter(filter_condition, Game.status.like('Final%')).scalar()
@@ -61,11 +65,11 @@ def aggregate_referee_stats(session, aggregation_type, aggregation_id, names_to_
61
65
  if start_datetime:
62
66
  game_window_filter = func.cast(func.concat(Game.date, ' ', Game.time), sqlalchemy.types.TIMESTAMP).between(start_datetime, last_game_datetime_str)
63
67
  filter_condition = filter_condition & game_window_filter
68
+ else:
69
+ #print(f"Warning: No valid start datetime for aggregation window '{aggregation_window}' for {aggregation_name}. No games will be included.")
70
+ return
64
71
 
65
- # Delete existing items from the stats table
66
- session.query(StatsModel).filter(StatsModel.aggregation_id == aggregation_id).delete()
67
- session.commit()
68
-
72
+ filter_condition = filter_condition & (Division.id == Game.division_id)
69
73
  # Aggregate games reffed for each referee
70
74
  games_reffed_stats = session.query(
71
75
  Game.referee_1_id.label('human_id'),
@@ -239,4 +243,4 @@ def run_aggregate_referee_stats():
239
243
  aggregate_referee_stats(session, aggregation_type='level', aggregation_id=level_id, names_to_filter_out=not_human_names)
240
244
 
241
245
  if __name__ == "__main__":
242
- run_aggregate_referee_stats()
246
+ run_aggregate_referee_stats()
@@ -65,6 +65,10 @@ def aggregate_skater_stats(session, aggregation_type, aggregation_id, names_to_f
65
65
  else:
66
66
  raise ValueError("Invalid aggregation type")
67
67
 
68
+ # Delete existing items from the stats table
69
+ session.query(StatsModel).filter(StatsModel.aggregation_id == aggregation_id).delete()
70
+ session.commit()
71
+
68
72
  # Apply aggregation window filter
69
73
  if aggregation_window:
70
74
  last_game_datetime_str = session.query(func.max(func.concat(Game.date, ' ', Game.time))).filter(filter_condition, Game.status.like('Final%')).scalar()
@@ -72,11 +76,10 @@ def aggregate_skater_stats(session, aggregation_type, aggregation_id, names_to_f
72
76
  if start_datetime:
73
77
  game_window_filter = func.cast(func.concat(Game.date, ' ', Game.time), sqlalchemy.types.TIMESTAMP).between(start_datetime, last_game_datetime_str)
74
78
  filter_condition = filter_condition & game_window_filter
75
-
76
- # Delete existing items from the stats table
77
- session.query(StatsModel).filter(StatsModel.aggregation_id == aggregation_id).delete()
78
- session.commit()
79
-
79
+ else:
80
+ #print(f"Warning: No valid start datetime for aggregation window '{aggregation_window}' for {aggregation_name}. No games will be included.")
81
+ return
82
+
80
83
  # Filter for specific human_id if provided
81
84
  human_filter = []
82
85
  # if debug_human_id:
@@ -85,13 +85,22 @@ def get_fake_human_for_stats(session):
85
85
  return human.id
86
86
 
87
87
  def get_start_datetime(last_game_datetime_str, aggregation_window):
88
+ if aggregation_window == 'Weekly':
89
+ if last_game_datetime_str:
90
+ last_game_datetime = datetime.strptime(last_game_datetime_str, '%Y-%m-%d %H:%M:%S')
91
+ # Check if the last game datetime is over 1 week from now
92
+ if datetime.now() - last_game_datetime > timedelta(weeks=1):
93
+ return None
94
+ # Use current time as the start of the weekly window
95
+ return datetime.now() - timedelta(weeks=1)
88
96
  if last_game_datetime_str:
89
97
  last_game_datetime = datetime.strptime(last_game_datetime_str, '%Y-%m-%d %H:%M:%S')
90
98
  if aggregation_window == 'Daily':
99
+ # Check if the last game datetime is over 24 hours from now
100
+ if datetime.now() - last_game_datetime > timedelta(hours=24):
101
+ return None
91
102
  # From 10AM till midnight, 14 hours to avoid last day games
92
103
  return last_game_datetime - timedelta(hours=14)
93
- elif aggregation_window == 'Weekly':
94
- return last_game_datetime - timedelta(weeks=1)
95
104
  return None
96
105
 
97
106
  def assign_ranks(stats_dict, field, reverse_rank=False):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hockey-blast-common-lib
3
- Version: 0.1.49
3
+ Version: 0.1.50
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.49',
5
+ version='0.1.50',
6
6
  description='Common library for shared functionality and DB models',
7
7
  author='Pavel Kletskov',
8
8
  author_email='kletskov@gmail.com',