hockey-blast-common-lib 0.1.65__py3-none-any.whl → 0.1.67__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_all_stats.py +14 -0
- hockey_blast_common_lib/aggregate_game_stats_all.py +150 -0
- hockey_blast_common_lib/aggregate_game_stats_goalie.py +257 -0
- hockey_blast_common_lib/aggregate_game_stats_skater.py +361 -0
- hockey_blast_common_lib/aggregate_goalie_stats.py +79 -0
- hockey_blast_common_lib/aggregate_human_stats.py +12 -0
- hockey_blast_common_lib/aggregate_referee_stats.py +75 -0
- hockey_blast_common_lib/aggregate_scorekeeper_stats.py +91 -0
- hockey_blast_common_lib/aggregate_skater_stats.py +118 -0
- hockey_blast_common_lib/aggregate_team_goalie_stats.py +265 -0
- hockey_blast_common_lib/aggregate_team_skater_stats.py +313 -0
- hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz +0 -0
- hockey_blast_common_lib/models.py +16 -1
- hockey_blast_common_lib/stats_models.py +211 -5
- hockey_blast_common_lib/utils.py +65 -0
- {hockey_blast_common_lib-0.1.65.dist-info → hockey_blast_common_lib-0.1.67.dist-info}/METADATA +1 -1
- hockey_blast_common_lib-0.1.67.dist-info/RECORD +34 -0
- hockey_blast_common_lib-0.1.65.dist-info/RECORD +0 -29
- {hockey_blast_common_lib-0.1.65.dist-info → hockey_blast_common_lib-0.1.67.dist-info}/WHEEL +0 -0
- {hockey_blast_common_lib-0.1.65.dist-info → hockey_blast_common_lib-0.1.67.dist-info}/top_level.txt +0 -0
hockey_blast_common_lib/utils.py
CHANGED
|
@@ -85,6 +85,7 @@ def get_non_human_ids(session):
|
|
|
85
85
|
|
|
86
86
|
Returns set of human_ids that should be filtered out from statistics.
|
|
87
87
|
Filters out placeholder names like "Home", "Away", "Unknown", etc.
|
|
88
|
+
Also excludes percentile marker humans.
|
|
88
89
|
"""
|
|
89
90
|
not_human_names = [
|
|
90
91
|
("Home", None, None),
|
|
@@ -97,7 +98,9 @@ def get_non_human_ids(session):
|
|
|
97
98
|
("Incognito", None, None),
|
|
98
99
|
("Empty", None , "Net"),
|
|
99
100
|
("Fake", "Stats", "Human"),
|
|
101
|
+
(None, None, "Percentile"),
|
|
100
102
|
]
|
|
103
|
+
|
|
101
104
|
return get_human_ids_by_names(session, not_human_names)
|
|
102
105
|
|
|
103
106
|
|
|
@@ -208,6 +211,68 @@ def get_fake_level(session):
|
|
|
208
211
|
return fake_skill
|
|
209
212
|
|
|
210
213
|
|
|
214
|
+
def get_percentile_human(session, entity_type, percentile):
|
|
215
|
+
"""Get or create a human record representing a percentile marker.
|
|
216
|
+
|
|
217
|
+
Args:
|
|
218
|
+
session: Database session
|
|
219
|
+
entity_type: One of "Skater", "Goalie", "Ref", "Scorekeeper"
|
|
220
|
+
percentile: One of 25, 50, 75, 90, 95
|
|
221
|
+
|
|
222
|
+
Returns:
|
|
223
|
+
human_id of the percentile marker record
|
|
224
|
+
"""
|
|
225
|
+
first_name = entity_type
|
|
226
|
+
middle_name = str(percentile)
|
|
227
|
+
last_name = "Percentile"
|
|
228
|
+
|
|
229
|
+
# Check if the human already exists
|
|
230
|
+
existing_human = (
|
|
231
|
+
session.query(Human)
|
|
232
|
+
.filter_by(first_name=first_name, middle_name=middle_name, last_name=last_name)
|
|
233
|
+
.first()
|
|
234
|
+
)
|
|
235
|
+
if existing_human:
|
|
236
|
+
return existing_human.id
|
|
237
|
+
|
|
238
|
+
# Create a new human
|
|
239
|
+
human = Human(first_name=first_name, middle_name=middle_name, last_name=last_name)
|
|
240
|
+
session.add(human)
|
|
241
|
+
session.commit()
|
|
242
|
+
|
|
243
|
+
return human.id
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def calculate_percentile_value(values, percentile):
|
|
247
|
+
"""Calculate the percentile value from a list of values.
|
|
248
|
+
|
|
249
|
+
Args:
|
|
250
|
+
values: List of numeric values
|
|
251
|
+
percentile: Percentile to calculate (e.g., 25, 50, 75, 90, 95)
|
|
252
|
+
|
|
253
|
+
Returns:
|
|
254
|
+
The value at the given percentile
|
|
255
|
+
"""
|
|
256
|
+
if not values:
|
|
257
|
+
return 0
|
|
258
|
+
|
|
259
|
+
sorted_values = sorted(values)
|
|
260
|
+
n = len(sorted_values)
|
|
261
|
+
|
|
262
|
+
# Calculate index (using linear interpolation method)
|
|
263
|
+
index = (percentile / 100.0) * (n - 1)
|
|
264
|
+
lower_index = int(index)
|
|
265
|
+
upper_index = min(lower_index + 1, n - 1)
|
|
266
|
+
|
|
267
|
+
# Interpolate if needed
|
|
268
|
+
fraction = index - lower_index
|
|
269
|
+
lower_value = sorted_values[lower_index]
|
|
270
|
+
upper_value = sorted_values[upper_index]
|
|
271
|
+
|
|
272
|
+
# Convert Decimal to float to avoid type errors with database Decimal fields
|
|
273
|
+
return float(lower_value) + fraction * (float(upper_value) - float(lower_value))
|
|
274
|
+
|
|
275
|
+
|
|
211
276
|
# TEST DB CONNECTION, PERMISSIONS...
|
|
212
277
|
# from hockey_blast_common_lib.db_connection import create_session
|
|
213
278
|
# session = create_session("frontend")
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
hockey_blast_common_lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
hockey_blast_common_lib/aggregate_all_stats.py,sha256=lWDhdYMYFEdNFTM3FmAKWiHFYSkb0OLjTkagguHlwls,1914
|
|
3
|
+
hockey_blast_common_lib/aggregate_game_stats_all.py,sha256=r0s2ki8y60pHL3wI8yDhRkAfNRRRgnOfzbJUwO6T4QY,4738
|
|
4
|
+
hockey_blast_common_lib/aggregate_game_stats_goalie.py,sha256=XMGhkCfj9EQ2kK1V8z0xLrCDi9t1Sqq0OxusG1uSXNk,9505
|
|
5
|
+
hockey_blast_common_lib/aggregate_game_stats_skater.py,sha256=00x8TUzPxClmfGZ7M6dPKUNJdYaCF1qIA6KmO7izI0Q,13013
|
|
6
|
+
hockey_blast_common_lib/aggregate_goalie_stats.py,sha256=hYhoCGf3p0lsLMYT11e-jqFLi3Yv2O3JmljdWRqww4I,20310
|
|
7
|
+
hockey_blast_common_lib/aggregate_h2h_stats.py,sha256=nStyIm_be25pKDYbPCaOSHFTjbaMLFxFAa2mTU1tL_k,11486
|
|
8
|
+
hockey_blast_common_lib/aggregate_human_stats.py,sha256=2NrdgKHQnaYHaM9tNjq8512Ea9RuySTRdzpRlHpkt7k,29741
|
|
9
|
+
hockey_blast_common_lib/aggregate_referee_stats.py,sha256=UUbd_YqdOFGFCRMcobU5ROfojKXKtcpEYJ8pL8Wqka8,20049
|
|
10
|
+
hockey_blast_common_lib/aggregate_s2s_stats.py,sha256=gB3Oi1emtBWL3bKojUhHH01gAbQTSLvgqO1WcvLI6F8,7449
|
|
11
|
+
hockey_blast_common_lib/aggregate_scorekeeper_stats.py,sha256=Bk6XOlv61kd1PwmWws8JEdsJt1nXnGEuDM1ecPaHEZM,18299
|
|
12
|
+
hockey_blast_common_lib/aggregate_skater_stats.py,sha256=ognlux7PFqRZS0YxW89aQGZkfdoG1Z0pjT8A9lrfATs,35339
|
|
13
|
+
hockey_blast_common_lib/aggregate_team_goalie_stats.py,sha256=ApgaR2beGmrV7docvDjXIGEACTt8f5T5pcmKisqLHpI,10044
|
|
14
|
+
hockey_blast_common_lib/aggregate_team_skater_stats.py,sha256=f93Dq884U47nlatWkyl4Tgtl-SvaBMg3pmR-rOJdWXU,12437
|
|
15
|
+
hockey_blast_common_lib/assign_skater_skill.py,sha256=it3jiSyUq7XpKqxzs88lyB5t1c3t1idIS_JRwq_FQoo,2810
|
|
16
|
+
hockey_blast_common_lib/db_connection.py,sha256=KACyHaOMeTX9zPNztYy8uOeB1ubIUenZcEKAeD5gC24,3333
|
|
17
|
+
hockey_blast_common_lib/dump_sample_db.sh,sha256=MY3lnzTXBoWd76-ZlZr9nWsKMEVgyRsUn-LZ2d1JWZs,810
|
|
18
|
+
hockey_blast_common_lib/embedding_utils.py,sha256=XbJvJlq6BKE6_oLzhUKcCrx6-TM8P-xl-S1SVLr_teU,10222
|
|
19
|
+
hockey_blast_common_lib/h2h_models.py,sha256=DEmQnmuacBVRNWvpRvq2RlwmhQYrT7XPOSTDNVtchr0,8597
|
|
20
|
+
hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz,sha256=dIAe4lsuCBQqE1WEkRyycEPYkAUlsA1scIU50SRalsI,4648840
|
|
21
|
+
hockey_blast_common_lib/models.py,sha256=HdSrKvNVvKNr2klvAinpj5aXiFxv9Vb0IrYkrIURj0o,22889
|
|
22
|
+
hockey_blast_common_lib/options.py,sha256=wzfGWKK_dHBA_PfiOvbP_-HtdoJCR0E7DkA5_cYDb_k,1578
|
|
23
|
+
hockey_blast_common_lib/progress_utils.py,sha256=7Txjpx5G4vHbnPTvNYuBA_WtrY0QFA4mDEYUDuZyY1E,3923
|
|
24
|
+
hockey_blast_common_lib/restore_sample_db.sh,sha256=7W3lzRZeu9zXIu1Bvtnaw8EHc1ulHmFM4mMh86oUQJo,2205
|
|
25
|
+
hockey_blast_common_lib/skills_in_divisions.py,sha256=9sGtU6SLj8BXb5R74ue1oPWa2nbk4JfJz5VmcuxetzA,8542
|
|
26
|
+
hockey_blast_common_lib/skills_propagation.py,sha256=qBK84nzkn8ZQHum0bdxFQwLvdgVE7DtWoPP9cdbOmRo,20201
|
|
27
|
+
hockey_blast_common_lib/stats_models.py,sha256=r-7cqStcIAO72gotRp1o8-HB4tXvJPsc4d3702gIQYM,39605
|
|
28
|
+
hockey_blast_common_lib/stats_utils.py,sha256=PTZvykl1zfEcojnzDFa1J3V3F5gREmoFG1lQHLnYHgo,300
|
|
29
|
+
hockey_blast_common_lib/utils.py,sha256=911NlMLzwMX5uwmytcpxNPRP-Y8OjDxTGKKIcyED5ls,9099
|
|
30
|
+
hockey_blast_common_lib/wsgi.py,sha256=oL9lPWccKLTAYIKPJkKZV5keVE-Dgosv74CBi770NNc,786
|
|
31
|
+
hockey_blast_common_lib-0.1.67.dist-info/METADATA,sha256=U8V1E5eCzhwWfqAX7sAPimvb6WpAsnO44AgNNb3q9tI,318
|
|
32
|
+
hockey_blast_common_lib-0.1.67.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
33
|
+
hockey_blast_common_lib-0.1.67.dist-info/top_level.txt,sha256=wIR4LIkE40npoA2QlOdfCYlgFeGbsHR8Z6r0h46Vtgc,24
|
|
34
|
+
hockey_blast_common_lib-0.1.67.dist-info/RECORD,,
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
hockey_blast_common_lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
hockey_blast_common_lib/aggregate_all_stats.py,sha256=ozILLB3-CRABYN9JHeH2sFeXw-sFhkXboU7sKTV2Ok8,1378
|
|
3
|
-
hockey_blast_common_lib/aggregate_goalie_stats.py,sha256=QPza_glSHcggt0KTwVB6USTkvEdP3yZj7GjpNeGjFE8,17433
|
|
4
|
-
hockey_blast_common_lib/aggregate_h2h_stats.py,sha256=nStyIm_be25pKDYbPCaOSHFTjbaMLFxFAa2mTU1tL_k,11486
|
|
5
|
-
hockey_blast_common_lib/aggregate_human_stats.py,sha256=uoGBkROBKh8n18TyzZ6vHX_viCTpHbRsiVLyflJq92g,29247
|
|
6
|
-
hockey_blast_common_lib/aggregate_referee_stats.py,sha256=YyFFHU2FJnXyUEzkzMnJoa5O28zjtF_spJeGedaI4QA,17389
|
|
7
|
-
hockey_blast_common_lib/aggregate_s2s_stats.py,sha256=gB3Oi1emtBWL3bKojUhHH01gAbQTSLvgqO1WcvLI6F8,7449
|
|
8
|
-
hockey_blast_common_lib/aggregate_scorekeeper_stats.py,sha256=r0CUsOSjeKwAEanrPSkqVufkxk9Iv_c125mKdhwR9Ns,14758
|
|
9
|
-
hockey_blast_common_lib/aggregate_skater_stats.py,sha256=chy-LcuNIGHP85h0FiXZT3nZrbGKbcr66_j-atrucXs,30706
|
|
10
|
-
hockey_blast_common_lib/assign_skater_skill.py,sha256=it3jiSyUq7XpKqxzs88lyB5t1c3t1idIS_JRwq_FQoo,2810
|
|
11
|
-
hockey_blast_common_lib/db_connection.py,sha256=KACyHaOMeTX9zPNztYy8uOeB1ubIUenZcEKAeD5gC24,3333
|
|
12
|
-
hockey_blast_common_lib/dump_sample_db.sh,sha256=MY3lnzTXBoWd76-ZlZr9nWsKMEVgyRsUn-LZ2d1JWZs,810
|
|
13
|
-
hockey_blast_common_lib/embedding_utils.py,sha256=XbJvJlq6BKE6_oLzhUKcCrx6-TM8P-xl-S1SVLr_teU,10222
|
|
14
|
-
hockey_blast_common_lib/h2h_models.py,sha256=DEmQnmuacBVRNWvpRvq2RlwmhQYrT7XPOSTDNVtchr0,8597
|
|
15
|
-
hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz,sha256=kakTyQVey1OuyS7RnbfXHBqeZ0_JrGG7p8WIQYt7azk,4648840
|
|
16
|
-
hockey_blast_common_lib/models.py,sha256=RQGUq8C8eJqUB2o3QCSs14W-9B4lMTUNvwNDM-Lc6j4,21687
|
|
17
|
-
hockey_blast_common_lib/options.py,sha256=wzfGWKK_dHBA_PfiOvbP_-HtdoJCR0E7DkA5_cYDb_k,1578
|
|
18
|
-
hockey_blast_common_lib/progress_utils.py,sha256=7Txjpx5G4vHbnPTvNYuBA_WtrY0QFA4mDEYUDuZyY1E,3923
|
|
19
|
-
hockey_blast_common_lib/restore_sample_db.sh,sha256=7W3lzRZeu9zXIu1Bvtnaw8EHc1ulHmFM4mMh86oUQJo,2205
|
|
20
|
-
hockey_blast_common_lib/skills_in_divisions.py,sha256=9sGtU6SLj8BXb5R74ue1oPWa2nbk4JfJz5VmcuxetzA,8542
|
|
21
|
-
hockey_blast_common_lib/skills_propagation.py,sha256=qBK84nzkn8ZQHum0bdxFQwLvdgVE7DtWoPP9cdbOmRo,20201
|
|
22
|
-
hockey_blast_common_lib/stats_models.py,sha256=t4nBxEr__dPJlO005jKvwQRWdUJwoXsALtVmW3crtdM,31100
|
|
23
|
-
hockey_blast_common_lib/stats_utils.py,sha256=PTZvykl1zfEcojnzDFa1J3V3F5gREmoFG1lQHLnYHgo,300
|
|
24
|
-
hockey_blast_common_lib/utils.py,sha256=hxlyOI1FR7B1tMfQbwyc16MJnHhze0WEuMdrzjI3xuY,7228
|
|
25
|
-
hockey_blast_common_lib/wsgi.py,sha256=oL9lPWccKLTAYIKPJkKZV5keVE-Dgosv74CBi770NNc,786
|
|
26
|
-
hockey_blast_common_lib-0.1.65.dist-info/METADATA,sha256=LXmzHHXKAe0uFdWulGQK0QyQ-sBMd83T8iCL5MG5vdo,318
|
|
27
|
-
hockey_blast_common_lib-0.1.65.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
28
|
-
hockey_blast_common_lib-0.1.65.dist-info/top_level.txt,sha256=wIR4LIkE40npoA2QlOdfCYlgFeGbsHR8Z6r0h46Vtgc,24
|
|
29
|
-
hockey_blast_common_lib-0.1.65.dist-info/RECORD,,
|
|
File without changes
|
{hockey_blast_common_lib-0.1.65.dist-info → hockey_blast_common_lib-0.1.67.dist-info}/top_level.txt
RENAMED
|
File without changes
|