hockey-blast-common-lib 0.1.54__tar.gz → 0.1.55__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.
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/PKG-INFO +1 -1
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/assign_skater_skill.py +12 -1
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/models.py +28 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/options.py +28 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/skills_propagation.py +17 -3
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib.egg-info/PKG-INFO +1 -1
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/setup.py +1 -1
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/MANIFEST.in +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/README.md +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/__init__.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/aggregate_all_stats.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/aggregate_goalie_stats.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/aggregate_h2h_stats.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/aggregate_human_stats.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/aggregate_referee_stats.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/aggregate_s2s_stats.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/aggregate_skater_stats.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/db_connection.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/dump_sample_db.sh +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/h2h_models.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/progress_utils.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/restore_sample_db.sh +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/skills_in_divisions.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/stats_models.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/stats_utils.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/utils.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/wsgi.py +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib.egg-info/SOURCES.txt +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib.egg-info/dependency_links.txt +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib.egg-info/requires.txt +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib.egg-info/top_level.txt +0 -0
- {hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/setup.cfg +0 -0
@@ -26,7 +26,7 @@ def calculate_skater_skill_value(session, level_stats):
|
|
26
26
|
|
27
27
|
# Apply skill adjustment: range from 0.8 to 1.2 of level base skill
|
28
28
|
# Since lower skill_value is better: Best player gets 0.8x (closer to better levels), worst gets 1.2x
|
29
|
-
skill_adjustment = 1.
|
29
|
+
skill_adjustment = 1.3 - 0.2 * ppg_skill_factor
|
30
30
|
skill_value = level_skill_value * skill_adjustment
|
31
31
|
|
32
32
|
# Take the minimum skill value across all levels the player has played in (lower is better)
|
@@ -43,15 +43,26 @@ def assign_skater_skill_values():
|
|
43
43
|
# Create progress tracker
|
44
44
|
progress = create_progress_tracker(total_humans, "Assigning skater skill values")
|
45
45
|
|
46
|
+
batch_size = 1000
|
47
|
+
updates_count = 0
|
48
|
+
|
46
49
|
for i, human in enumerate(humans):
|
47
50
|
level_stats = session.query(LevelStatsSkater).filter(LevelStatsSkater.human_id == human.id).all()
|
48
51
|
if level_stats:
|
49
52
|
skater_skill_value = calculate_skater_skill_value(session, level_stats)
|
50
53
|
human.skater_skill_value = skater_skill_value
|
54
|
+
updates_count += 1
|
55
|
+
|
56
|
+
# Commit in batches
|
57
|
+
if updates_count % batch_size == 0:
|
51
58
|
session.commit()
|
52
59
|
|
53
60
|
progress.update(i + 1)
|
54
61
|
|
62
|
+
# Commit any remaining updates
|
63
|
+
if updates_count % batch_size != 0:
|
64
|
+
session.commit()
|
65
|
+
|
55
66
|
print("Skater skill values have been assigned to all humans.")
|
56
67
|
|
57
68
|
if __name__ == "__main__":
|
Binary file
|
{hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/models.py
RENAMED
@@ -52,6 +52,8 @@ class Game(db.Model):
|
|
52
52
|
home_period_1_score = db.Column(db.Integer)
|
53
53
|
home_period_2_score = db.Column(db.Integer)
|
54
54
|
home_period_3_score = db.Column(db.Integer)
|
55
|
+
home_ot_score = db.Column(db.Integer, default=0)
|
56
|
+
visitor_ot_score = db.Column(db.Integer, default=0)
|
55
57
|
game_type = db.Column(db.String(50))
|
56
58
|
went_to_ot = db.Column(db.Boolean, default=False)
|
57
59
|
home_period_1_shots = db.Column(db.Integer)
|
@@ -92,6 +94,7 @@ class Goal(db.Model):
|
|
92
94
|
goal_scorer_id = db.Column(db.Integer, db.ForeignKey('humans.id'))
|
93
95
|
assist_1_id = db.Column(db.Integer, db.ForeignKey('humans.id'))
|
94
96
|
assist_2_id = db.Column(db.Integer, db.ForeignKey('humans.id'))
|
97
|
+
goalie_id = db.Column(db.Integer, db.ForeignKey('humans.id'), nullable=True) # Goalie who allowed the goal (can be "Empty Net" special human)
|
95
98
|
special_condition = db.Column(db.String(50)) # e.g., PP (power play), SH (short-handed)
|
96
99
|
sequence_number = db.Column(db.Integer)
|
97
100
|
__table_args__ = (
|
@@ -357,6 +360,31 @@ class RequestLog(db.Model):
|
|
357
360
|
cgi_params = db.Column(db.String, nullable=True)
|
358
361
|
response_time_ms = db.Column(db.Float, nullable=True) # Response time in milliseconds
|
359
362
|
|
363
|
+
class GoalieSaves(db.Model):
|
364
|
+
__tablename__ = 'goalie_saves'
|
365
|
+
id = db.Column(db.Integer, primary_key=True)
|
366
|
+
game_id = db.Column(db.Integer, db.ForeignKey('games.id'), nullable=False)
|
367
|
+
goalie_id = db.Column(db.Integer, db.ForeignKey('humans.id'), nullable=False)
|
368
|
+
saves_count = db.Column(db.Integer, nullable=False, default=0)
|
369
|
+
shots_against = db.Column(db.Integer, nullable=False, default=0)
|
370
|
+
goals_allowed = db.Column(db.Integer, nullable=False, default=0)
|
371
|
+
__table_args__ = (
|
372
|
+
db.UniqueConstraint('game_id', 'goalie_id', name='_game_goalie_saves_uc'),
|
373
|
+
)
|
374
|
+
|
375
|
+
class ScorekeeperSaveQuality(db.Model):
|
376
|
+
__tablename__ = 'scorekeeper_save_quality'
|
377
|
+
id = db.Column(db.Integer, primary_key=True)
|
378
|
+
game_id = db.Column(db.Integer, db.ForeignKey('games.id'), nullable=False)
|
379
|
+
scorekeeper_id = db.Column(db.Integer, db.ForeignKey('humans.id'), nullable=False)
|
380
|
+
total_saves_recorded = db.Column(db.Integer, nullable=False, default=0)
|
381
|
+
max_saves_per_5sec = db.Column(db.Integer, nullable=False, default=0) # Highest saves in any 5-second window
|
382
|
+
max_saves_per_20sec = db.Column(db.Integer, nullable=False, default=0) # Highest saves in any 20-second window
|
383
|
+
saves_timestamps = db.Column(db.JSON, nullable=True) # JSONB with home_saves/away_saves arrays of decisecond timestamps
|
384
|
+
__table_args__ = (
|
385
|
+
db.UniqueConstraint('game_id', 'scorekeeper_id', name='_game_scorekeeper_quality_uc'),
|
386
|
+
)
|
387
|
+
|
360
388
|
# # MANUAL AMENDS HAPPEN HERE :)
|
361
389
|
# from db_connection import create_session
|
362
390
|
# session = create_session("sharksice")
|
{hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/options.py
RENAMED
@@ -1,4 +1,5 @@
|
|
1
1
|
import argparse
|
2
|
+
from .models import Human
|
2
3
|
|
3
4
|
MAX_HUMAN_SEARCH_RESULTS = 25
|
4
5
|
MAX_TEAM_SEARCH_RESULTS = 25
|
@@ -23,3 +24,30 @@ def parse_args():
|
|
23
24
|
parser.add_argument("--reprocess", action="store_true", help="Reprocess existing data.")
|
24
25
|
parser.add_argument("--pre_process", action="store_true", help="Pre-Process existing data.")
|
25
26
|
return parser.parse_args()
|
27
|
+
|
28
|
+
def get_or_create_empty_net_human(session, game_date):
|
29
|
+
"""Get or create the special 'Empty Net' human record for tracking pulled goalies.
|
30
|
+
|
31
|
+
Args:
|
32
|
+
session: Database session
|
33
|
+
game_date: Date of the game (used for first_date/last_date if creating)
|
34
|
+
|
35
|
+
Returns:
|
36
|
+
int: The human_id of the Empty Net special record
|
37
|
+
"""
|
38
|
+
empty_net_human = session.query(Human).filter_by(
|
39
|
+
first_name="Empty", middle_name="", last_name="Net"
|
40
|
+
).first()
|
41
|
+
|
42
|
+
if not empty_net_human:
|
43
|
+
empty_net_human = Human(
|
44
|
+
first_name="Empty",
|
45
|
+
middle_name="",
|
46
|
+
last_name="Net",
|
47
|
+
first_date=game_date,
|
48
|
+
last_date=game_date
|
49
|
+
)
|
50
|
+
session.add(empty_net_human)
|
51
|
+
session.commit()
|
52
|
+
|
53
|
+
return empty_net_human.id
|
@@ -11,6 +11,7 @@ from hockey_blast_common_lib.stats_models import LevelsGraphEdge, LevelStatsSkat
|
|
11
11
|
from hockey_blast_common_lib.db_connection import create_session
|
12
12
|
from hockey_blast_common_lib.progress_utils import create_progress_tracker
|
13
13
|
from sqlalchemy import func
|
14
|
+
from sqlalchemy.exc import IntegrityError
|
14
15
|
|
15
16
|
import numpy as np
|
16
17
|
|
@@ -93,9 +94,22 @@ def reset_skill_values_in_divisions():
|
|
93
94
|
skill_propagation_sequence=-1
|
94
95
|
)
|
95
96
|
session.add(new_level)
|
96
|
-
|
97
|
-
|
98
|
-
|
97
|
+
try:
|
98
|
+
session.commit()
|
99
|
+
division.level_id = new_level.id
|
100
|
+
print(f"Created new Level for Division {division.level}")
|
101
|
+
except IntegrityError:
|
102
|
+
session.rollback()
|
103
|
+
# Another process created this level, query for it
|
104
|
+
existing_level = session.query(Level).filter(
|
105
|
+
Level.org_id == division.org_id,
|
106
|
+
Level.level_name == division.level
|
107
|
+
).first()
|
108
|
+
if existing_level:
|
109
|
+
division.level_id = existing_level.id
|
110
|
+
print(f"Race condition resolved - using existing Level for Division {division.level}")
|
111
|
+
else:
|
112
|
+
raise RuntimeError(f"Unable to create or find level: {division.level} for org_id: {division.org_id}")
|
99
113
|
|
100
114
|
# Commit the changes to the Division
|
101
115
|
session.commit()
|
@@ -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.
|
5
|
+
version='0.1.55',
|
6
6
|
description='Common library for shared functionality and DB models',
|
7
7
|
author='Pavel Kletskov',
|
8
8
|
author_email='kletskov@gmail.com',
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/utils.py
RENAMED
File without changes
|
{hockey_blast_common_lib-0.1.54 → hockey_blast_common_lib-0.1.55}/hockey_blast_common_lib/wsgi.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|