hockey-blast-common-lib 0.1.31__py3-none-any.whl → 0.1.32__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.
@@ -3,17 +3,19 @@ import sys, os
3
3
  # Add the package directory to the Python path
4
4
  sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
5
5
 
6
- from hockey_blast_common_lib.models import Human, LevelStatsSkater
6
+ from hockey_blast_common_lib.models import Human, Level
7
+ from hockey_blast_common_lib.stats_models import LevelStatsSkater
7
8
  from hockey_blast_common_lib.db_connection import create_session
8
9
  from sqlalchemy.sql import func
9
10
 
10
- def calculate_skater_skill_value(human_id, level_stats):
11
+ def calculate_skater_skill_value(session, human_id, level_stats):
11
12
  max_skill_value = 0
12
13
 
13
14
  for stat in level_stats:
14
- level_skill_value = stat.level.skill_value
15
- if level_skill_value < 0:
15
+ level = session.query(Level).filter(Level.id == stat.level_id).first()
16
+ if not level or level.skill_value < 0:
16
17
  continue
18
+ level_skill_value = level.skill_value
17
19
  ppg_ratio = stat.points_per_game_rank / stat.total_in_rank
18
20
  games_played_ratio = stat.games_played_rank / stat.total_in_rank
19
21
 
@@ -33,7 +35,7 @@ def assign_skater_skill_values():
33
35
  for human in humans:
34
36
  level_stats = session.query(LevelStatsSkater).filter(LevelStatsSkater.human_id == human.id).all()
35
37
  if level_stats:
36
- skater_skill_value = calculate_skater_skill_value(human.id, level_stats)
38
+ skater_skill_value = calculate_skater_skill_value(session, human.id, level_stats)
37
39
  human.skater_skill_value = skater_skill_value
38
40
  session.commit()
39
41
 
@@ -106,6 +106,7 @@ class Human(db.Model):
106
106
  last_name = db.Column(db.String(100))
107
107
  first_date = db.Column(db.Date)
108
108
  last_date = db.Column(db.Date)
109
+ skater_skill_value = db.Column(db.Float, nullable=True)
109
110
  __table_args__ = (
110
111
  db.UniqueConstraint('first_name', 'middle_name', 'last_name', name='_human_name_uc'),
111
112
  )
@@ -140,6 +140,5 @@ def populate_league_ids():
140
140
  if __name__ == "__main__":
141
141
  # delete_all_skills()
142
142
  #fill_seed_skills()
143
- reset_skill_values_in_divisions()
144
143
  #populate_season_ids() # Call the function to populate season_ids
145
144
  #populate_league_ids() # Call the new function to populate league_ids
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hockey-blast-common-lib
3
- Version: 0.1.31
3
+ Version: 0.1.32
4
4
  Summary: Common library for shared functionality and DB models
5
5
  Author: Pavel Kletskov
6
6
  Author-email: kletskov@gmail.com
@@ -3,19 +3,19 @@ hockey_blast_common_lib/aggregate_goalie_stats.py,sha256=d2qav46Rg2DNIYRj_Ubj1kp
3
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=A0PTyEbPUjqfXxlJCDOVioFaQk9AyjjhiWEuRuu35v0,11036
5
5
  hockey_blast_common_lib/aggregate_skater_stats.py,sha256=jkBD5u-gJc1DTDIEuxM_qymKsrWtLagFKeEn__2rFgU,16009
6
- hockey_blast_common_lib/assign_skater_skill.py,sha256=YQYYWKArkvqPsu7shlRzggE-p_7rcEMO3VtnzKQHPG0,1657
6
+ hockey_blast_common_lib/assign_skater_skill.py,sha256=p-0fbodGpM8BCjKHDpxNb7BH2FcIlBsJwON844KNrUY,1817
7
7
  hockey_blast_common_lib/db_connection.py,sha256=HvPxDvOj7j5H85RfslGvHVNevfg7mKCd0syJ6NX21mU,1890
8
8
  hockey_blast_common_lib/dump_sample_db.sh,sha256=MHPA-Ciod7wsvAlMbRtXFiyajgnEqU1xR59sJQ9UWR0,738
9
- hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz,sha256=Flm7M1rDuz-psuBg_gtlo1JhjjJRjnBMGy-gTwgMhjM,1033685
10
- hockey_blast_common_lib/models.py,sha256=2YkFHgzvxLSU2-fURsyIqdaXjcQwZ_wjauYR9wWQtDw,15924
9
+ hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz,sha256=fO5SsdPB6XYptPLx1rD2VVSTySLnJmyubeSS0A0HGyw,1033692
10
+ hockey_blast_common_lib/models.py,sha256=ebRnnvDOVNDfqAp8CA8u7uk3LCOfI3iUwOpHgzoBy0U,15984
11
11
  hockey_blast_common_lib/options.py,sha256=6na8fo-5A2RBPpd_h-7dsqetOLSLoNEJg1QMYgl4jNs,792
12
12
  hockey_blast_common_lib/restore_sample_db.sh,sha256=u2zKazC6vNMULkpYzI64nlneCWaGUtDHPBAU-gWgRbw,1861
13
- hockey_blast_common_lib/skills_in_divisions.py,sha256=tQYSikIV9AN_Cr-770KRy4reaiiR-2vvtwaNPJ8Lvws,7524
13
+ hockey_blast_common_lib/skills_in_divisions.py,sha256=LV6f2nzmRi1IHl1_EDVf61I7nHUNc0xYuNL4dBsZI_U,7486
14
14
  hockey_blast_common_lib/skills_propagation.py,sha256=x6yy7fJ6IX3YiHqiP_v7-p_S2Expb8JJ-mWuajEFBdY,16388
15
15
  hockey_blast_common_lib/stats_models.py,sha256=35-6iz1r8MJcmzlyIlJy0uHgWh8oltyf-3H61ocal3o,23048
16
16
  hockey_blast_common_lib/utils.py,sha256=odDJWCK0BgbResXeoUzxbVChjaxcXr168ZxbrAw3L_8,3752
17
17
  hockey_blast_common_lib/wsgi.py,sha256=7LGUzioigviJp-EUhSEaQcd4jBae0mxbkyBscQfZhlc,730
18
- hockey_blast_common_lib-0.1.31.dist-info/METADATA,sha256=F19EMmlAfN34YH4YhXsATH-TdZ3ROGICcIU-T10A5yw,318
19
- hockey_blast_common_lib-0.1.31.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
20
- hockey_blast_common_lib-0.1.31.dist-info/top_level.txt,sha256=wIR4LIkE40npoA2QlOdfCYlgFeGbsHR8Z6r0h46Vtgc,24
21
- hockey_blast_common_lib-0.1.31.dist-info/RECORD,,
18
+ hockey_blast_common_lib-0.1.32.dist-info/METADATA,sha256=DZgI2eRmWQGFrcaxenwqrWLZdWmgDK5LbU57iLTlI0w,318
19
+ hockey_blast_common_lib-0.1.32.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
20
+ hockey_blast_common_lib-0.1.32.dist-info/top_level.txt,sha256=wIR4LIkE40npoA2QlOdfCYlgFeGbsHR8Z6r0h46Vtgc,24
21
+ hockey_blast_common_lib-0.1.32.dist-info/RECORD,,