hockey-blast-common-lib 0.1.50__tar.gz → 0.1.51__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.50 → hockey_blast_common_lib-0.1.51}/PKG-INFO +1 -1
- hockey_blast_common_lib-0.1.51/hockey_blast_common_lib/aggregate_h2h_stats.py +230 -0
- hockey_blast_common_lib-0.1.51/hockey_blast_common_lib/h2h_models.py +77 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/wsgi.py +1 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib.egg-info/PKG-INFO +1 -1
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib.egg-info/SOURCES.txt +2 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/setup.py +1 -1
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/MANIFEST.in +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/README.md +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/__init__.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/aggregate_all_stats.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/aggregate_goalie_stats.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/aggregate_human_stats.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/aggregate_referee_stats.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/aggregate_skater_stats.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/assign_skater_skill.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/db_connection.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/dump_sample_db.sh +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/models.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/options.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/restore_sample_db.sh +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/skills_in_divisions.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/skills_propagation.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/stats_models.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/stats_utils.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/utils.py +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib.egg-info/dependency_links.txt +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib.egg-info/requires.txt +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib.egg-info/top_level.txt +0 -0
- {hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/setup.cfg +0 -0
@@ -0,0 +1,230 @@
|
|
1
|
+
import sys, os
|
2
|
+
from datetime import datetime
|
3
|
+
|
4
|
+
# Add the package directory to the Python path
|
5
|
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
6
|
+
|
7
|
+
from hockey_blast_common_lib.models import Game, GameRoster, Goal, Penalty
|
8
|
+
from hockey_blast_common_lib.h2h_models import H2HStats, H2HStatsMeta
|
9
|
+
from hockey_blast_common_lib.db_connection import create_session
|
10
|
+
from sqlalchemy.sql import func
|
11
|
+
from sqlalchemy import types
|
12
|
+
|
13
|
+
# Max games to process (set to None to process all)
|
14
|
+
MAX_GAMES_TO_PROCESS = None # Set to None to process all games
|
15
|
+
|
16
|
+
def aggregate_h2h_stats():
|
17
|
+
session = create_session("boss")
|
18
|
+
meta = None #session.query(H2HStatsMeta).order_by(H2HStatsMeta.id.desc()).first()
|
19
|
+
h2h_stats_dict = {} # (h1, h2) -> H2HStats instance
|
20
|
+
if meta is None or meta.last_run_timestamp is None or meta.last_processed_game_id is None:
|
21
|
+
# Full run: delete all existing stats and process all games
|
22
|
+
session.query(H2HStats).delete()
|
23
|
+
session.commit()
|
24
|
+
games_query = session.query(Game).order_by(Game.date, Game.time, Game.id)
|
25
|
+
print("No previous run found, deleted all existing H2H stats, processing all games...")
|
26
|
+
else:
|
27
|
+
# Incremental: only process games after last processed
|
28
|
+
# Load all existing stats into memory
|
29
|
+
for stat in session.query(H2HStats).all():
|
30
|
+
h2h_stats_dict[(stat.human1_id, stat.human2_id)] = stat
|
31
|
+
last_game = session.query(Game).filter(Game.id == meta.last_processed_game_id).first()
|
32
|
+
if last_game:
|
33
|
+
last_dt = datetime.combine(last_game.date, last_game.time)
|
34
|
+
games_query = session.query(Game).filter(
|
35
|
+
func.cast(func.concat(Game.date, ' ', Game.time), types.TIMESTAMP()) > last_dt
|
36
|
+
).order_by(Game.date, Game.time, Game.id)
|
37
|
+
print(f"Resuming from game after id {meta.last_processed_game_id} ({last_dt})...")
|
38
|
+
else:
|
39
|
+
games_query = session.query(Game).order_by(Game.date, Game.time, Game.id)
|
40
|
+
print("Previous game id not found, processing all games...")
|
41
|
+
|
42
|
+
total_games = games_query.count()
|
43
|
+
print(f"Total games to process: {total_games}")
|
44
|
+
processed = 0
|
45
|
+
latest_game_id = None
|
46
|
+
for game in games_query:
|
47
|
+
if MAX_GAMES_TO_PROCESS is not None and processed >= MAX_GAMES_TO_PROCESS:
|
48
|
+
break
|
49
|
+
# --- Gather all relevant data for this game ---
|
50
|
+
# Get all GameRoster entries for this game
|
51
|
+
rosters = session.query(GameRoster).filter(GameRoster.game_id == game.id).all()
|
52
|
+
# Map: team_id -> set of human_ids (players)
|
53
|
+
team_to_players = {}
|
54
|
+
human_roles = {} # human_id -> set of roles in this game
|
55
|
+
for roster in rosters:
|
56
|
+
team_to_players.setdefault(roster.team_id, set()).add(roster.human_id)
|
57
|
+
human_roles.setdefault(roster.human_id, set()).add(roster.role)
|
58
|
+
# Get all human_ids in this game
|
59
|
+
all_humans = set(human_roles.keys())
|
60
|
+
# Add goalies from Game table (home/visitor)
|
61
|
+
if game.home_goalie_id:
|
62
|
+
all_humans.add(game.home_goalie_id)
|
63
|
+
human_roles.setdefault(game.home_goalie_id, set()).add('G')
|
64
|
+
if game.visitor_goalie_id:
|
65
|
+
all_humans.add(game.visitor_goalie_id)
|
66
|
+
human_roles.setdefault(game.visitor_goalie_id, set()).add('G')
|
67
|
+
# Add referees from Game table (NOT from roster!)
|
68
|
+
if game.referee_1_id:
|
69
|
+
all_humans.add(game.referee_1_id)
|
70
|
+
human_roles.setdefault(game.referee_1_id, set()).add('R')
|
71
|
+
if game.referee_2_id:
|
72
|
+
all_humans.add(game.referee_2_id)
|
73
|
+
human_roles.setdefault(game.referee_2_id, set()).add('R')
|
74
|
+
# --- Build all pairs of humans in this game ---
|
75
|
+
all_humans = list(all_humans)
|
76
|
+
for i in range(len(all_humans)):
|
77
|
+
for j in range(i+1, len(all_humans)):
|
78
|
+
h1, h2 = sorted([all_humans[i], all_humans[j]])
|
79
|
+
key = (h1, h2)
|
80
|
+
h2h = h2h_stats_dict.get(key)
|
81
|
+
if not h2h:
|
82
|
+
h2h = H2HStats(
|
83
|
+
human1_id=h1,
|
84
|
+
human2_id=h2,
|
85
|
+
first_game_id=game.id,
|
86
|
+
last_game_id=game.id,
|
87
|
+
games_together=0,
|
88
|
+
games_against=0,
|
89
|
+
games_tied_together=0,
|
90
|
+
games_tied_against=0,
|
91
|
+
wins_together=0,
|
92
|
+
losses_together=0,
|
93
|
+
h1_wins_vs_h2=0,
|
94
|
+
h2_wins_vs_h1=0,
|
95
|
+
games_h1_goalie=0,
|
96
|
+
games_h2_goalie=0,
|
97
|
+
games_h1_ref=0,
|
98
|
+
games_h2_ref=0,
|
99
|
+
games_both_referees=0,
|
100
|
+
goals_h1_when_together=0,
|
101
|
+
goals_h2_when_together=0,
|
102
|
+
assists_h1_when_together=0,
|
103
|
+
assists_h2_when_together=0,
|
104
|
+
penalties_h1_when_together=0,
|
105
|
+
penalties_h2_when_together=0,
|
106
|
+
gm_penalties_h1_when_together=0,
|
107
|
+
gm_penalties_h2_when_together=0,
|
108
|
+
h1_goalie_h2_scorer_goals=0,
|
109
|
+
h2_goalie_h1_scorer_goals=0,
|
110
|
+
shots_faced_h1_goalie_vs_h2=0,
|
111
|
+
shots_faced_h2_goalie_vs_h1=0,
|
112
|
+
goals_allowed_h1_goalie_vs_h2=0,
|
113
|
+
goals_allowed_h2_goalie_vs_h1=0,
|
114
|
+
save_percentage_h1_goalie_vs_h2=0.0,
|
115
|
+
save_percentage_h2_goalie_vs_h1=0.0,
|
116
|
+
h1_ref_h2_player_games=0,
|
117
|
+
h2_ref_h1_player_games=0,
|
118
|
+
h1_ref_penalties_on_h2=0,
|
119
|
+
h2_ref_penalties_on_h1=0,
|
120
|
+
h1_ref_gm_penalties_on_h2=0,
|
121
|
+
h2_ref_gm_penalties_on_h1=0,
|
122
|
+
penalties_given_both_refs=0,
|
123
|
+
gm_penalties_given_both_refs=0,
|
124
|
+
h1_shootout_attempts_vs_h2_goalie=0,
|
125
|
+
h1_shootout_goals_vs_h2_goalie=0,
|
126
|
+
h2_shootout_attempts_vs_h1_goalie=0,
|
127
|
+
h2_shootout_goals_vs_h1_goalie=0
|
128
|
+
)
|
129
|
+
h2h_stats_dict[key] = h2h
|
130
|
+
# Update first/last game ids
|
131
|
+
if game.id < h2h.first_game_id:
|
132
|
+
h2h.first_game_id = game.id
|
133
|
+
if game.id > h2h.last_game_id:
|
134
|
+
h2h.last_game_id = game.id
|
135
|
+
# --- Determine roles and teams ---
|
136
|
+
h1_roles = human_roles.get(h1, set())
|
137
|
+
h2_roles = human_roles.get(h2, set())
|
138
|
+
h1_team = None
|
139
|
+
h2_team = None
|
140
|
+
for team_id, players in team_to_players.items():
|
141
|
+
if h1 in players:
|
142
|
+
h1_team = team_id
|
143
|
+
if h2 in players:
|
144
|
+
h2_team = team_id
|
145
|
+
# --- General stats ---
|
146
|
+
h2h.games_together += 1 # Both present in this game
|
147
|
+
if h1_team and h2_team:
|
148
|
+
if h1_team == h2_team:
|
149
|
+
h2h.wins_together += int(_is_win(game, h1_team))
|
150
|
+
h2h.losses_together += int(_is_loss(game, h1_team))
|
151
|
+
if _is_tie(game):
|
152
|
+
h2h.games_tied_together += 1
|
153
|
+
else:
|
154
|
+
h2h.games_against += 1
|
155
|
+
if _is_win(game, h1_team):
|
156
|
+
h2h.h1_wins_vs_h2 += 1
|
157
|
+
if _is_win(game, h2_team):
|
158
|
+
h2h.h2_wins_vs_h1 += 1
|
159
|
+
if _is_tie(game):
|
160
|
+
h2h.games_tied_against += 1
|
161
|
+
# --- Role-specific stats ---
|
162
|
+
if 'G' in h1_roles:
|
163
|
+
h2h.games_h1_goalie += 1
|
164
|
+
if 'G' in h2_roles:
|
165
|
+
h2h.games_h2_goalie += 1
|
166
|
+
if 'R' in h1_roles:
|
167
|
+
h2h.games_h1_ref += 1
|
168
|
+
if 'R' in h2_roles:
|
169
|
+
h2h.games_h2_ref += 1
|
170
|
+
if 'R' in h1_roles and 'R' in h2_roles:
|
171
|
+
h2h.games_both_referees += 1
|
172
|
+
# --- Goals, assists, penalties ---
|
173
|
+
# Goals
|
174
|
+
goals = session.query(Goal).filter(Goal.game_id == game.id).all()
|
175
|
+
for goal in goals:
|
176
|
+
if goal.goal_scorer_id == h1 and (goal.assist_1_id == h2 or goal.assist_2_id == h2):
|
177
|
+
h2h.goals_h1_when_together += 1
|
178
|
+
if goal.goal_scorer_id == h2 and (goal.assist_1_id == h1 or goal.assist_2_id == h1):
|
179
|
+
h2h.goals_h2_when_together += 1
|
180
|
+
# Penalties
|
181
|
+
penalties = session.query(Penalty).filter(Penalty.game_id == game.id).all()
|
182
|
+
for pen in penalties:
|
183
|
+
if pen.penalized_player_id == h1:
|
184
|
+
h2h.penalties_h1_when_together += 1
|
185
|
+
if pen.penalty_minutes and 'GM' in pen.penalty_minutes:
|
186
|
+
h2h.gm_penalties_h1_when_together += 1
|
187
|
+
if pen.penalized_player_id == h2:
|
188
|
+
h2h.penalties_h2_when_together += 1
|
189
|
+
if pen.penalty_minutes and 'GM' in pen.penalty_minutes:
|
190
|
+
h2h.gm_penalties_h2_when_together += 1
|
191
|
+
# --- TODO: Add more detailed logic for goalie/skater, referee/player, shootouts, etc. ---
|
192
|
+
latest_game_id = game.id
|
193
|
+
processed += 1
|
194
|
+
if processed % 10 == 0 or processed == total_games:
|
195
|
+
print(f"\rProcessed {processed}/{total_games} games ({(processed/total_games)*100:.2f}%)", end="")
|
196
|
+
sys.stdout.flush()
|
197
|
+
# Commit all stats at once
|
198
|
+
session.query(H2HStats).delete()
|
199
|
+
session.add_all(list(h2h_stats_dict.values()))
|
200
|
+
session.commit()
|
201
|
+
print(f"\rProcessed {processed}/{total_games} games (100.00%)")
|
202
|
+
# Save/update meta
|
203
|
+
meta = H2HStatsMeta(
|
204
|
+
last_run_timestamp=datetime.utcnow(),
|
205
|
+
last_processed_game_id=latest_game_id
|
206
|
+
)
|
207
|
+
session.add(meta)
|
208
|
+
session.commit()
|
209
|
+
print("H2H aggregation complete.")
|
210
|
+
|
211
|
+
# --- Helper functions for win/loss/tie ---
|
212
|
+
def _is_win(game, team_id):
|
213
|
+
if team_id == game.home_team_id:
|
214
|
+
return (game.home_final_score or 0) > (game.visitor_final_score or 0)
|
215
|
+
if team_id == game.visitor_team_id:
|
216
|
+
return (game.visitor_final_score or 0) > (game.home_final_score or 0)
|
217
|
+
return False
|
218
|
+
|
219
|
+
def _is_loss(game, team_id):
|
220
|
+
if team_id == game.home_team_id:
|
221
|
+
return (game.home_final_score or 0) < (game.visitor_final_score or 0)
|
222
|
+
if team_id == game.visitor_team_id:
|
223
|
+
return (game.visitor_final_score or 0) < (game.home_final_score or 0)
|
224
|
+
return False
|
225
|
+
|
226
|
+
def _is_tie(game):
|
227
|
+
return (game.home_final_score is not None and game.visitor_final_score is not None and game.home_final_score == game.visitor_final_score)
|
228
|
+
|
229
|
+
if __name__ == "__main__":
|
230
|
+
aggregate_h2h_stats()
|
@@ -0,0 +1,77 @@
|
|
1
|
+
from hockey_blast_common_lib.models import db
|
2
|
+
|
3
|
+
class H2HStats(db.Model):
|
4
|
+
__tablename__ = 'h2h_stats'
|
5
|
+
id = db.Column(db.Integer, primary_key=True)
|
6
|
+
human1_id = db.Column(db.Integer, db.ForeignKey('humans.id'), nullable=False)
|
7
|
+
human2_id = db.Column(db.Integer, db.ForeignKey('humans.id'), nullable=False)
|
8
|
+
# Always store with human1_id < human2_id for uniqueness
|
9
|
+
__table_args__ = (
|
10
|
+
db.UniqueConstraint('human1_id', 'human2_id', name='_h2h_human_pair_uc'),
|
11
|
+
db.Index('ix_h2h_human_pair', 'human1_id', 'human2_id'), # Composite index for fast lookup
|
12
|
+
)
|
13
|
+
|
14
|
+
# General
|
15
|
+
games_together = db.Column(db.Integer, default=0, nullable=False) # Games where both played (any role, any team)
|
16
|
+
games_against = db.Column(db.Integer, default=0, nullable=False) # Games where both played on opposing teams
|
17
|
+
games_tied_together = db.Column(db.Integer, default=0, nullable=False)
|
18
|
+
games_tied_against = db.Column(db.Integer, default=0, nullable=False) # Games against each other that ended in a tie
|
19
|
+
wins_together = db.Column(db.Integer, default=0, nullable=False) # Games both played on same team and won
|
20
|
+
losses_together = db.Column(db.Integer, default=0, nullable=False) # Games both played on same team and lost
|
21
|
+
h1_wins_vs_h2 = db.Column(db.Integer, default=0, nullable=False) # Games h1's team won vs h2's team
|
22
|
+
h2_wins_vs_h1 = db.Column(db.Integer, default=0, nullable=False) # Games h2's team won vs h1's team
|
23
|
+
|
24
|
+
# Role-specific counts
|
25
|
+
games_h1_goalie = db.Column(db.Integer, default=0, nullable=False) # Games where h1 was a goalie and h2 played
|
26
|
+
games_h2_goalie = db.Column(db.Integer, default=0, nullable=False) # Games where h2 was a goalie and h1 played
|
27
|
+
games_h1_ref = db.Column(db.Integer, default=0, nullable=False) # Games where h1 was a referee and h2 played
|
28
|
+
games_h2_ref = db.Column(db.Integer, default=0, nullable=False) # Games where h2 was a referee and h1 played
|
29
|
+
games_both_referees = db.Column(db.Integer, default=0, nullable=False) # Games where both were referees
|
30
|
+
|
31
|
+
# Goals/Assists/Penalties (when both played)
|
32
|
+
goals_h1_when_together = db.Column(db.Integer, default=0, nullable=False) # Goals by h1 when both played
|
33
|
+
goals_h2_when_together = db.Column(db.Integer, default=0, nullable=False) # Goals by h2 when both played
|
34
|
+
assists_h1_when_together = db.Column(db.Integer, default=0, nullable=False) # Assists by h1 when both played
|
35
|
+
assists_h2_when_together = db.Column(db.Integer, default=0, nullable=False) # Assists by h2 when both played
|
36
|
+
penalties_h1_when_together = db.Column(db.Integer, default=0, nullable=False) # Penalties on h1 when both played
|
37
|
+
penalties_h2_when_together = db.Column(db.Integer, default=0, nullable=False) # Penalties on h2 when both played
|
38
|
+
gm_penalties_h1_when_together = db.Column(db.Integer, default=0, nullable=False) # GM penalties on h1 when both played
|
39
|
+
gm_penalties_h2_when_together = db.Column(db.Integer, default=0, nullable=False) # GM penalties on h2 when both played
|
40
|
+
|
41
|
+
# Goalie/Skater head-to-head (when one is goalie, other is skater on opposing team)
|
42
|
+
h1_goalie_h2_scorer_goals = db.Column(db.Integer, default=0, nullable=False) # Goals scored by h2 against h1 as goalie
|
43
|
+
h2_goalie_h1_scorer_goals = db.Column(db.Integer, default=0, nullable=False) # Goals scored by h1 against h2 as goalie
|
44
|
+
shots_faced_h1_goalie_vs_h2 = db.Column(db.Integer, default=0, nullable=False) # Shots faced by h1 as goalie vs h2 as skater
|
45
|
+
shots_faced_h2_goalie_vs_h1 = db.Column(db.Integer, default=0, nullable=False) # Shots faced by h2 as goalie vs h1 as skater
|
46
|
+
goals_allowed_h1_goalie_vs_h2 = db.Column(db.Integer, default=0, nullable=False) # Goals allowed by h1 as goalie vs h2 as skater
|
47
|
+
goals_allowed_h2_goalie_vs_h1 = db.Column(db.Integer, default=0, nullable=False) # Goals allowed by h2 as goalie vs h1 as skater
|
48
|
+
save_percentage_h1_goalie_vs_h2 = db.Column(db.Float, default=0.0, nullable=False) # Save % by h1 as goalie vs h2 as skater
|
49
|
+
save_percentage_h2_goalie_vs_h1 = db.Column(db.Float, default=0.0, nullable=False) # Save % by h2 as goalie vs h1 as skater
|
50
|
+
|
51
|
+
# Referee/Player
|
52
|
+
h1_ref_h2_player_games = db.Column(db.Integer, default=0, nullable=False) # Games h1 was referee, h2 was player
|
53
|
+
h2_ref_h1_player_games = db.Column(db.Integer, default=0, nullable=False) # Games h2 was referee, h1 was player
|
54
|
+
h1_ref_penalties_on_h2 = db.Column(db.Integer, default=0, nullable=False) # Penalties given by h1 (as ref) to h2
|
55
|
+
h2_ref_penalties_on_h1 = db.Column(db.Integer, default=0, nullable=False) # Penalties given by h2 (as ref) to h1
|
56
|
+
h1_ref_gm_penalties_on_h2 = db.Column(db.Integer, default=0, nullable=False) # GM penalties given by h1 (as ref) to h2
|
57
|
+
h2_ref_gm_penalties_on_h1 = db.Column(db.Integer, default=0, nullable=False) # GM penalties given by h2 (as ref) to h1
|
58
|
+
|
59
|
+
# Both referees (when both are referees in the same game)
|
60
|
+
penalties_given_both_refs = db.Column(db.Integer, default=0, nullable=False) # Total penalties given by both
|
61
|
+
gm_penalties_given_both_refs = db.Column(db.Integer, default=0, nullable=False) # Total GM penalties given by both
|
62
|
+
|
63
|
+
# Shootouts
|
64
|
+
h1_shootout_attempts_vs_h2_goalie = db.Column(db.Integer, default=0, nullable=False) # h1 shootout attempts vs h2 as goalie
|
65
|
+
h1_shootout_goals_vs_h2_goalie = db.Column(db.Integer, default=0, nullable=False) # h1 shootout goals vs h2 as goalie
|
66
|
+
h2_shootout_attempts_vs_h1_goalie = db.Column(db.Integer, default=0, nullable=False) # h2 shootout attempts vs h1 as goalie
|
67
|
+
h2_shootout_goals_vs_h1_goalie = db.Column(db.Integer, default=0, nullable=False) # h2 shootout goals vs h1 as goalie
|
68
|
+
|
69
|
+
# First and last game IDs where both were present
|
70
|
+
first_game_id = db.Column(db.Integer, nullable=False) # Game.id of the first game where both were present
|
71
|
+
last_game_id = db.Column(db.Integer, nullable=False) # Game.id of the most recent game where both were present
|
72
|
+
|
73
|
+
class H2HStatsMeta(db.Model):
|
74
|
+
__tablename__ = 'h2h_stats_meta'
|
75
|
+
id = db.Column(db.Integer, primary_key=True)
|
76
|
+
last_run_timestamp = db.Column(db.DateTime, nullable=True) # When the h2h stats were last updated
|
77
|
+
last_processed_game_id = db.Column(db.Integer, nullable=True) # Game.id of the latest processed game
|
Binary file
|
{hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/wsgi.py
RENAMED
@@ -6,6 +6,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
6
6
|
from flask_migrate import Migrate
|
7
7
|
from flask import Flask
|
8
8
|
from hockey_blast_common_lib.models import *
|
9
|
+
from hockey_blast_common_lib.h2h_models import *
|
9
10
|
from hockey_blast_common_lib.stats_models import *
|
10
11
|
from hockey_blast_common_lib.stats_models import db
|
11
12
|
from hockey_blast_common_lib.db_connection import get_db_params
|
@@ -4,12 +4,14 @@ setup.py
|
|
4
4
|
hockey_blast_common_lib/__init__.py
|
5
5
|
hockey_blast_common_lib/aggregate_all_stats.py
|
6
6
|
hockey_blast_common_lib/aggregate_goalie_stats.py
|
7
|
+
hockey_blast_common_lib/aggregate_h2h_stats.py
|
7
8
|
hockey_blast_common_lib/aggregate_human_stats.py
|
8
9
|
hockey_blast_common_lib/aggregate_referee_stats.py
|
9
10
|
hockey_blast_common_lib/aggregate_skater_stats.py
|
10
11
|
hockey_blast_common_lib/assign_skater_skill.py
|
11
12
|
hockey_blast_common_lib/db_connection.py
|
12
13
|
hockey_blast_common_lib/dump_sample_db.sh
|
14
|
+
hockey_blast_common_lib/h2h_models.py
|
13
15
|
hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz
|
14
16
|
hockey_blast_common_lib/models.py
|
15
17
|
hockey_blast_common_lib/options.py
|
@@ -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.51',
|
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
|
{hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/models.py
RENAMED
File without changes
|
{hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/options.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{hockey_blast_common_lib-0.1.50 → hockey_blast_common_lib-0.1.51}/hockey_blast_common_lib/utils.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|