hockey-blast-common-lib 0.1.9__py3-none-any.whl → 0.1.10__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.
@@ -5,13 +5,12 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
5
5
 
6
6
  from datetime import datetime, timedelta
7
7
  import sqlalchemy
8
- from options import not_human_names
9
8
  from hockey_blast_common_lib.models import Game, GameRoster
10
- from stats_models import OrgStatsGoalie, DivisionStatsGoalie, OrgStatsWeeklyGoalie, OrgStatsDailyGoalie, DivisionStatsWeeklyGoalie, DivisionStatsDailyGoalie
11
- from db_connection import create_session
9
+ from hockey_blast_common_lib.stats_models import OrgStatsGoalie, DivisionStatsGoalie, OrgStatsWeeklyGoalie, OrgStatsDailyGoalie, DivisionStatsWeeklyGoalie, DivisionStatsDailyGoalie
10
+ from hockey_blast_common_lib.db_connection import create_session
12
11
  from sqlalchemy.sql import func, case
13
- from options import parse_args, MIN_GAMES_FOR_ORG_STATS, MIN_GAMES_FOR_DIVISION_STATS
14
- from 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
12
+ from hockey_blast_common_lib.options import not_human_names, parse_args, MIN_GAMES_FOR_ORG_STATS, MIN_GAMES_FOR_DIVISION_STATS
13
+ 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
14
 
16
15
  def aggregate_goalie_stats(session, aggregation_type, aggregation_id, names_to_filter_out, aggregation_window=None):
17
16
  human_ids_to_filter = get_human_ids_by_names(session, names_to_filter_out)
@@ -7,12 +7,11 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
7
7
  from datetime import datetime, timedelta
8
8
  import sqlalchemy
9
9
  from hockey_blast_common_lib.models import Game, GameRoster
10
- from stats_models import OrgStatsHuman, DivisionStatsHuman, OrgStatsDailyHuman, OrgStatsWeeklyHuman, DivisionStatsDailyHuman, DivisionStatsWeeklyHuman
11
- from db_connection import create_session
10
+ from hockey_blast_common_lib.stats_models import OrgStatsHuman, DivisionStatsHuman, OrgStatsDailyHuman, OrgStatsWeeklyHuman, DivisionStatsDailyHuman, DivisionStatsWeeklyHuman
11
+ from hockey_blast_common_lib.db_connection import create_session
12
12
  from sqlalchemy.sql import func, case
13
- from options import parse_args, MIN_GAMES_FOR_ORG_STATS, MIN_GAMES_FOR_DIVISION_STATS, not_human_names
14
- from utils import get_org_id_from_alias, get_human_ids_by_names, get_division_ids_for_last_season_in_all_leagues
15
- from db_utils import get_fake_human_for_stats
13
+ from hockey_blast_common_lib.options import parse_args, MIN_GAMES_FOR_ORG_STATS, MIN_GAMES_FOR_DIVISION_STATS, not_human_names
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
16
15
 
17
16
  def aggregate_human_stats(session, aggregation_type, aggregation_id, names_to_filter_out, human_id_filter=None, aggregation_window=None):
18
17
  human_ids_to_filter = get_human_ids_by_names(session, names_to_filter_out)
@@ -1,5 +1,9 @@
1
1
  import sys
2
2
  import os
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
+
3
7
  from datetime import datetime, timedelta
4
8
 
5
9
 
@@ -63,3 +67,26 @@ def get_division_ids_for_last_season_in_all_leagues(session, org_id):
63
67
  def get_all_division_ids_for_org(session, org_id):
64
68
  division_ids_for_org = session.query(Division.id).filter_by(org_id=org_id).all()
65
69
  return [division_id.id for division_id in division_ids_for_org]
70
+
71
+ def get_fake_human_for_stats(session):
72
+ first_name = "Fake"
73
+ middle_name = "Stats"
74
+ last_name = "Human"
75
+
76
+ # Check if the human already exists
77
+ existing_human = session.query(Human).filter_by(first_name=first_name, middle_name=middle_name, last_name=last_name).first()
78
+ if existing_human:
79
+ return existing_human.id
80
+
81
+ # Create a new human
82
+ human = Human(first_name=first_name, middle_name=middle_name, last_name=last_name)
83
+ session.add(human)
84
+ session.commit() # Commit to get the human.id
85
+
86
+ return human.id
87
+
88
+ # TEST DB CONNECTION, PERMISSIONS...
89
+ # from hockey_blast_common_lib.db_connection import create_session
90
+ # session = create_session("hockey-blast-radonly")
91
+ # human_id = get_fake_human_for_stats(session)
92
+ # print(f"Human ID: {human_id}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hockey-blast-common-lib
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: Common library for shared functionality and DB models
5
5
  Author: Pavel Kletskov
6
6
  Author-email: kletskov@gmail.com
@@ -1,16 +1,15 @@
1
1
  hockey_blast_common_lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- hockey_blast_common_lib/aggregate_goalie_stats.py,sha256=-q4dBjROsRljmG4SXDdJjezRHvqyJ5D7xb8-Uj6HWaE,8665
3
- hockey_blast_common_lib/aggregate_human_stats.py,sha256=-QpMHWGOYRq3uxr6jUNUnLb8UYSYoHEFrx6zyegrTzI,14153
2
+ hockey_blast_common_lib/aggregate_goalie_stats.py,sha256=d2qav46Rg2DNIYRj_Ubj1kpQmoPUJHKiwEWOVU25nD4,8742
3
+ hockey_blast_common_lib/aggregate_human_stats.py,sha256=88OMhTgQjzc9xIakf6kW9_lZwbSXkpsZy8C0pX-Wlq8,14229
4
4
  hockey_blast_common_lib/aggregate_referee_stats.py,sha256=-vABfO88hlWwh8lfv6afST861SmqCdayVT8KAXwixG4,10940
5
5
  hockey_blast_common_lib/aggregate_skater_stats.py,sha256=hD8QUFtxpbAuxSzJJecn2ccaYTISEOM83lRdo05e-20,15486
6
6
  hockey_blast_common_lib/db_connection.py,sha256=JJcYbBuGlstMfui7UwP5GxPRwzrh4PxtsZDpWsQPnqA,998
7
- hockey_blast_common_lib/db_utils.py,sha256=tN_cT587VqEfgYc7Nt-M-Mm_DwIHDxwPYA2Lmd1b_bw,791
8
7
  hockey_blast_common_lib/models.py,sha256=GqQIGpanmFub97BoYCuaqDov2MxM4LMesUTxZ2edpvw,15393
9
8
  hockey_blast_common_lib/options.py,sha256=-LtEX8duw5Pl3CSpjFlLM5FPvrZuTAxTfSlDPa7H6mQ,761
10
9
  hockey_blast_common_lib/stats_models.py,sha256=PI-mL1jmjCHLAvaATxSsjHEn05g9L_reA_YpsITPWjQ,21047
11
- hockey_blast_common_lib/utils.py,sha256=LhHfa-fI1j6_Er0eHlXiCPNQkty2G3CxSYgfFw_Taq8,2899
10
+ hockey_blast_common_lib/utils.py,sha256=-dZpkVr5GOupeTCC40Dl-yZSinLlEqzIL3_zgq_TnAs,3808
12
11
  hockey_blast_common_lib/wsgi.py,sha256=Qpux4NpQQnZ2U3gOAsqualn-bv9cLjFaXQtFQinC0j4,513
13
- hockey_blast_common_lib-0.1.9.dist-info/METADATA,sha256=t2HdAROSvQcVYwtQBu1UncZx5_JGboGoaBviUIZS9jg,317
14
- hockey_blast_common_lib-0.1.9.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
15
- hockey_blast_common_lib-0.1.9.dist-info/top_level.txt,sha256=wIR4LIkE40npoA2QlOdfCYlgFeGbsHR8Z6r0h46Vtgc,24
16
- hockey_blast_common_lib-0.1.9.dist-info/RECORD,,
12
+ hockey_blast_common_lib-0.1.10.dist-info/METADATA,sha256=OybKHhUIdc0fUdPl1ekJYqyjASzxN_FdabwxcGFr8MU,318
13
+ hockey_blast_common_lib-0.1.10.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
14
+ hockey_blast_common_lib-0.1.10.dist-info/top_level.txt,sha256=wIR4LIkE40npoA2QlOdfCYlgFeGbsHR8Z6r0h46Vtgc,24
15
+ hockey_blast_common_lib-0.1.10.dist-info/RECORD,,
@@ -1,26 +0,0 @@
1
- import sys
2
- import os
3
-
4
- from hockey_blast_common_lib.models import Human
5
- from db_connection import create_session
6
-
7
- def get_fake_human_for_stats(session):
8
- first_name = "Fake"
9
- middle_name = "Stats"
10
- last_name = "Human"
11
-
12
- # Check if the human already exists
13
- existing_human = session.query(Human).filter_by(first_name=first_name, middle_name=middle_name, last_name=last_name).first()
14
- if existing_human:
15
- return existing_human.id
16
-
17
- # Create a new human
18
- human = Human(first_name=first_name, middle_name=middle_name, last_name=last_name)
19
- session.add(human)
20
- session.commit() # Commit to get the human.id
21
-
22
- return human.id
23
-
24
- # session = create_session("hockey-blast-radonly")
25
- # human_id = get_fake_human_for_stats(session)
26
- # print(f"Human ID: {human_id}")