hockey-blast-common-lib 0.1.37__tar.gz → 0.1.39__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.37 → hockey_blast_common_lib-0.1.39}/PKG-INFO +1 -1
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/aggregate_goalie_stats.py +7 -10
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/aggregate_human_stats.py +20 -15
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/aggregate_referee_stats.py +7 -2
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/aggregate_skater_stats.py +8 -4
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/models.py +1 -0
- hockey_blast_common_lib-0.1.39/hockey_blast_common_lib/stats_utils.py +6 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib.egg-info/PKG-INFO +1 -1
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/setup.py +1 -1
- hockey_blast_common_lib-0.1.37/hockey_blast_common_lib/stats_utils.py +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/MANIFEST.in +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/README.md +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/__init__.py +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/aggregate_all_stats.py +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/assign_skater_skill.py +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/db_connection.py +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/dump_sample_db.sh +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/options.py +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/restore_sample_db.sh +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/skills_in_divisions.py +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/skills_propagation.py +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/stats_models.py +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/utils.py +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/wsgi.py +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib.egg-info/SOURCES.txt +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib.egg-info/dependency_links.txt +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib.egg-info/requires.txt +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib.egg-info/top_level.txt +0 -0
- {hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/setup.cfg +0 -0
@@ -15,22 +15,20 @@ from hockey_blast_common_lib.utils import get_org_id_from_alias, get_human_ids_b
|
|
15
15
|
from hockey_blast_common_lib.utils import assign_ranks
|
16
16
|
from sqlalchemy import func, case, and_
|
17
17
|
from collections import defaultdict
|
18
|
+
from hockey_blast_common_lib.stats_utils import ALL_ORGS_ID
|
18
19
|
|
19
20
|
def aggregate_goalie_stats(session, aggregation_type, aggregation_id, names_to_filter_out, debug_human_id=None, aggregation_window=None):
|
20
21
|
human_ids_to_filter = get_human_ids_by_names(session, names_to_filter_out)
|
21
22
|
|
22
23
|
# Get the name of the aggregation, for debug purposes
|
23
24
|
if aggregation_type == 'org':
|
24
|
-
|
25
|
+
if aggregation_id == ALL_ORGS_ID:
|
26
|
+
aggregation_name = "All Orgs"
|
27
|
+
filter_condition = sqlalchemy.true() # No filter for organization
|
28
|
+
else:
|
29
|
+
aggregation_name = session.query(Organization).filter(Organization.id == aggregation_id).first().organization_name
|
30
|
+
filter_condition = Game.org_id == aggregation_id
|
25
31
|
print(f"Aggregating goalie stats for {aggregation_name} with window {aggregation_window}...")
|
26
|
-
elif aggregation_type == 'division':
|
27
|
-
aggregation_name = session.query(Division).filter(Division.id == aggregation_id).first().level
|
28
|
-
elif aggregation_type == 'level':
|
29
|
-
aggregation_name = session.query(Level).filter(Level.id == aggregation_id).first().level_name
|
30
|
-
else:
|
31
|
-
aggregation_name = "Unknown"
|
32
|
-
|
33
|
-
if aggregation_type == 'org':
|
34
32
|
if aggregation_window == 'Daily':
|
35
33
|
StatsModel = OrgStatsDailyGoalie
|
36
34
|
elif aggregation_window == 'Weekly':
|
@@ -38,7 +36,6 @@ def aggregate_goalie_stats(session, aggregation_type, aggregation_id, names_to_f
|
|
38
36
|
else:
|
39
37
|
StatsModel = OrgStatsGoalie
|
40
38
|
min_games = MIN_GAMES_FOR_ORG_STATS
|
41
|
-
filter_condition = Game.org_id == aggregation_id
|
42
39
|
elif aggregation_type == 'division':
|
43
40
|
if aggregation_window == 'Daily':
|
44
41
|
StatsModel = DivisionStatsDailyGoalie
|
@@ -14,13 +14,19 @@ from hockey_blast_common_lib.options import parse_args, MIN_GAMES_FOR_ORG_STATS,
|
|
14
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
|
15
15
|
from hockey_blast_common_lib.utils import assign_ranks
|
16
16
|
from hockey_blast_common_lib.utils import get_start_datetime
|
17
|
+
from hockey_blast_common_lib.stats_utils import ALL_ORGS_ID
|
17
18
|
|
18
19
|
def aggregate_human_stats(session, aggregation_type, aggregation_id, names_to_filter_out, human_id_filter=None, aggregation_window=None):
|
19
20
|
human_ids_to_filter = get_human_ids_by_names(session, names_to_filter_out)
|
20
21
|
|
21
22
|
if aggregation_type == 'org':
|
22
|
-
|
23
|
-
|
23
|
+
if aggregation_id == ALL_ORGS_ID:
|
24
|
+
aggregation_name = "All Orgs"
|
25
|
+
filter_condition = sqlalchemy.true() # No filter for organization
|
26
|
+
else:
|
27
|
+
aggregation_name = session.query(Organization).filter(Organization.id == aggregation_id).first().organization_name
|
28
|
+
filter_condition = Game.org_id == aggregation_id
|
29
|
+
print(f"Aggregating human stats for {aggregation_name} with window {aggregation_window}...")
|
24
30
|
if aggregation_window == 'Daily':
|
25
31
|
StatsModel = OrgStatsDailyHuman
|
26
32
|
elif aggregation_window == 'Weekly':
|
@@ -28,7 +34,6 @@ def aggregate_human_stats(session, aggregation_type, aggregation_id, names_to_fi
|
|
28
34
|
else:
|
29
35
|
StatsModel = OrgStatsHuman
|
30
36
|
min_games = MIN_GAMES_FOR_ORG_STATS
|
31
|
-
filter_condition = Game.org_id == aggregation_id
|
32
37
|
elif aggregation_type == 'division':
|
33
38
|
if aggregation_window == 'Daily':
|
34
39
|
StatsModel = DivisionStatsDailyHuman
|
@@ -417,7 +422,7 @@ def run_aggregate_human_stats():
|
|
417
422
|
org_ids = session.query(Organization.id).all()
|
418
423
|
org_ids = [org_id[0] for org_id in org_ids]
|
419
424
|
|
420
|
-
for org_id in org_ids:
|
425
|
+
for org_id in [-1]:#org_ids:
|
421
426
|
division_ids = get_all_division_ids_for_org(session, org_id)
|
422
427
|
print(f"Aggregating human stats for {len(division_ids)} divisions in org_id {org_id}...")
|
423
428
|
total_divisions = len(division_ids)
|
@@ -435,17 +440,17 @@ def run_aggregate_human_stats():
|
|
435
440
|
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')
|
436
441
|
|
437
442
|
# Aggregate by level
|
438
|
-
level_ids = session.query(Division.level_id).distinct().all()
|
439
|
-
level_ids = [level_id[0] for level_id in level_ids]
|
440
|
-
total_levels = len(level_ids)
|
441
|
-
processed_levels = 0
|
442
|
-
for level_id in level_ids:
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
443
|
+
# level_ids = session.query(Division.level_id).distinct().all()
|
444
|
+
# level_ids = [level_id[0] for level_id in level_ids]
|
445
|
+
# total_levels = len(level_ids)
|
446
|
+
# processed_levels = 0
|
447
|
+
# for level_id in level_ids:
|
448
|
+
# if level_id is None:
|
449
|
+
# continue
|
450
|
+
# if human_id_to_debug is None:
|
451
|
+
# print(f"\rProcessed {processed_levels}/{total_levels} levels ({(processed_levels/total_levels)*100:.2f}%)", end="")
|
452
|
+
# processed_levels += 1
|
453
|
+
# 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)
|
449
454
|
|
450
455
|
if __name__ == "__main__":
|
451
456
|
run_aggregate_human_stats()
|
@@ -14,12 +14,18 @@ from hockey_blast_common_lib.options import parse_args, MIN_GAMES_FOR_ORG_STATS,
|
|
14
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
|
15
15
|
from hockey_blast_common_lib.utils import assign_ranks
|
16
16
|
from hockey_blast_common_lib.utils import get_start_datetime
|
17
|
+
from hockey_blast_common_lib.stats_utils import ALL_ORGS_ID
|
17
18
|
|
18
19
|
def aggregate_referee_stats(session, aggregation_type, aggregation_id, names_to_filter_out, aggregation_window=None):
|
19
20
|
human_ids_to_filter = get_human_ids_by_names(session, names_to_filter_out)
|
20
21
|
|
21
22
|
if aggregation_type == 'org':
|
22
|
-
|
23
|
+
if aggregation_id == ALL_ORGS_ID:
|
24
|
+
aggregation_name = "All Orgs"
|
25
|
+
filter_condition = sqlalchemy.true() # No filter for organization
|
26
|
+
else:
|
27
|
+
aggregation_name = session.query(Organization).filter(Organization.id == aggregation_id).first().organization_name
|
28
|
+
filter_condition = Game.org_id == aggregation_id
|
23
29
|
print(f"Aggregating referee stats for {aggregation_name} with window {aggregation_window}...")
|
24
30
|
if aggregation_window == 'Daily':
|
25
31
|
StatsModel = OrgStatsDailyReferee
|
@@ -28,7 +34,6 @@ def aggregate_referee_stats(session, aggregation_type, aggregation_id, names_to_
|
|
28
34
|
else:
|
29
35
|
StatsModel = OrgStatsReferee
|
30
36
|
min_games = MIN_GAMES_FOR_ORG_STATS
|
31
|
-
filter_condition = Game.org_id == aggregation_id
|
32
37
|
elif aggregation_type == 'division':
|
33
38
|
if aggregation_window == 'Daily':
|
34
39
|
StatsModel = DivisionStatsDailyReferee
|
@@ -15,16 +15,21 @@ from hockey_blast_common_lib.utils import get_org_id_from_alias, get_human_ids_b
|
|
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
|
18
|
+
from hockey_blast_common_lib.stats_utils import ALL_ORGS_ID
|
18
19
|
|
19
20
|
def aggregate_skater_stats(session, aggregation_type, aggregation_id, names_to_filter_out, debug_human_id=None, aggregation_window=None):
|
20
21
|
human_ids_to_filter = get_human_ids_by_names(session, names_to_filter_out)
|
21
22
|
|
22
23
|
# Get the name of the aggregation, for debug purposes
|
23
24
|
if aggregation_type == 'org':
|
24
|
-
|
25
|
+
if aggregation_id == ALL_ORGS_ID:
|
26
|
+
aggregation_name = "All Orgs"
|
27
|
+
filter_condition = sqlalchemy.true() # No filter for organization
|
28
|
+
else:
|
29
|
+
aggregation_name = session.query(Organization).filter(Organization.id == aggregation_id).first().organization_name
|
30
|
+
filter_condition = Game.org_id == aggregation_id
|
25
31
|
print(f"Aggregating skater stats for {aggregation_name} with window {aggregation_window}...")
|
26
32
|
|
27
|
-
aggregation_name = session.query(Organization).filter(Organization.id == aggregation_id).first().organization_name
|
28
33
|
elif aggregation_type == 'division':
|
29
34
|
aggregation_name = session.query(Division).filter(Division.id == aggregation_id).first().level
|
30
35
|
elif aggregation_type == 'level':
|
@@ -40,7 +45,6 @@ def aggregate_skater_stats(session, aggregation_type, aggregation_id, names_to_f
|
|
40
45
|
else:
|
41
46
|
StatsModel = OrgStatsSkater
|
42
47
|
min_games = MIN_GAMES_FOR_ORG_STATS
|
43
|
-
filter_condition = Game.org_id == aggregation_id
|
44
48
|
elif aggregation_type == 'division':
|
45
49
|
if aggregation_window == 'Daily':
|
46
50
|
StatsModel = DivisionStatsDailySkater
|
@@ -278,7 +282,7 @@ def run_aggregate_skater_stats():
|
|
278
282
|
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')
|
279
283
|
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')
|
280
284
|
|
281
|
-
|
285
|
+
# Aggregate by level
|
282
286
|
level_ids = session.query(Division.level_id).distinct().all()
|
283
287
|
level_ids = [level_id[0] for level_id in level_ids]
|
284
288
|
total_levels = len(level_ids)
|
Binary file
|
{hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/models.py
RENAMED
@@ -350,6 +350,7 @@ class RequestLog(db.Model):
|
|
350
350
|
client_ip = db.Column(db.String, nullable=False)
|
351
351
|
path = db.Column(db.String, nullable=False)
|
352
352
|
timestamp = db.Column(db.DateTime, nullable=False)
|
353
|
+
cgi_params = db.Column(db.String, nullable=True)
|
353
354
|
|
354
355
|
# # MANUAL AMENDS HAPPEN HERE :)
|
355
356
|
# from db_connection import create_session
|
@@ -0,0 +1,6 @@
|
|
1
|
+
def assign_ranks(stats_dict, field, reverse_rank=False):
|
2
|
+
sorted_stats = sorted(stats_dict.items(), key=lambda x: x[1][field], reverse=not reverse_rank)
|
3
|
+
for rank, (key, stat) in enumerate(sorted_stats, start=1):
|
4
|
+
stats_dict[key][f'{field}_rank'] = rank
|
5
|
+
|
6
|
+
ALL_ORGS_ID = -1
|
@@ -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.39',
|
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
|
{hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/options.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/hockey_blast_common_lib/utils.py
RENAMED
File without changes
|
{hockey_blast_common_lib-0.1.37 → hockey_blast_common_lib-0.1.39}/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
|