Clear excess logging
This commit is contained in:
parent
4e60c11b3d
commit
1a9f15b489
@ -565,12 +565,12 @@ class CardColumn(pydantic.BaseModel):
|
||||
|
||||
return False
|
||||
|
||||
logging.info(f'Not a whole number | Chances: {chances}')
|
||||
logging.debug(f'Not a whole number | Chances: {chances}')
|
||||
if chances in EXACT_CHANCES and self.num_splits < 4 and secondary_play is not None:
|
||||
logging.info(f'In Exact Chances!')
|
||||
logging.debug(f'In Exact Chances!')
|
||||
if chances >= 3:
|
||||
self.num_splits += 1
|
||||
logging.info(f'Chances is greater than 3')
|
||||
logging.debug(f'Chances is greater than 3')
|
||||
if chances == Decimal('3.2'):
|
||||
if not self.five.is_full():
|
||||
self.five.assign_play(play, secondary_play, 16)
|
||||
@ -676,7 +676,7 @@ class CardColumn(pydantic.BaseModel):
|
||||
return chances, Decimal('0.3')
|
||||
elif chances >= 1:
|
||||
self.num_splits += 1
|
||||
logging.info(f'Chances is greater than 1')
|
||||
logging.debug(f'Chances is greater than 1')
|
||||
if chances == Decimal('1.05'):
|
||||
if not self.four.is_full():
|
||||
self.four.assign_play(play, secondary_play, 7)
|
||||
@ -944,18 +944,18 @@ class CardColumn(pydantic.BaseModel):
|
||||
self.ten.assign_play(play, secondary_play, 19)
|
||||
return chances, Decimal('0.15')
|
||||
else:
|
||||
logging.info(f'Chances is less than 1')
|
||||
logging.debug(f'Chances is less than 1')
|
||||
return False
|
||||
|
||||
self.num_splits -= 1
|
||||
|
||||
else:
|
||||
logging.info(f'Not a whole number and not in Exact Chances! Trying to add a subset')
|
||||
logging.debug(f'Not a whole number and not in Exact Chances! Trying to add a subset')
|
||||
for x in EXACT_CHANCES:
|
||||
if x < chances and ((chances - x) == round(chances - x)):
|
||||
logging.info(f'Trying to add {x} chances')
|
||||
logging.debug(f'Trying to add {x} chances')
|
||||
return self.add_result(play, alt_direction, x, secondary_play)
|
||||
logging.info(f'Could not find a valid match')
|
||||
logging.debug(f'Could not find a valid match')
|
||||
return False
|
||||
|
||||
def total_chances(self):
|
||||
@ -1366,7 +1366,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
def assign_bchances(
|
||||
this_card: FullBattingCard, play: PlayResult, chances: Decimal,
|
||||
secondary_play: Optional[PlayResult] = None):
|
||||
logging.info(f'Assign batting chances\n{play}\nChances: {chances}\nBackup: {secondary_play}')
|
||||
logging.debug(f'Assign batting chances\n{play}\nChances: {chances}\nBackup: {secondary_play}')
|
||||
r_data = this_card.add_result(play, chances, secondary_play)
|
||||
if r_data:
|
||||
return r_data
|
||||
@ -1429,7 +1429,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
while res_chances > 0:
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_bchances(card, PLAY_RESULTS['bp-hr'], ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.bp_homerun += r_val[0]
|
||||
@ -1443,7 +1443,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_bchances(card, PlayResult(full_name='HBP', short_name='HBP'), ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.hbp += r_val[0]
|
||||
@ -1489,7 +1489,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
secondary = None
|
||||
|
||||
r_val = assign_bchances(card, PLAY_RESULTS['hr'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.homerun += r_val[0]
|
||||
@ -1550,7 +1550,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
secondary = None
|
||||
|
||||
r_val = assign_bchances(card, PLAY_RESULTS['tr'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.triple += r_val[0]
|
||||
@ -1609,7 +1609,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
secondary = None
|
||||
|
||||
r_val = assign_bchances(card, PLAY_RESULTS['do***'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.double_three += r_val[0]
|
||||
@ -1661,7 +1661,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
secondary = None
|
||||
|
||||
r_val = assign_bchances(card, PLAY_RESULTS[f'do-{pull_of}'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.double_pull += r_val[0]
|
||||
@ -1713,7 +1713,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
secondary = None
|
||||
|
||||
r_val = assign_bchances(card, PLAY_RESULTS['do**'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.double_two += r_val[0]
|
||||
@ -1757,7 +1757,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
secondary = None
|
||||
|
||||
r_val = assign_bchances(card, PLAY_RESULTS['si**'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.single_two += r_val[0]
|
||||
@ -1804,7 +1804,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
secondary = None
|
||||
|
||||
r_val = assign_bchances(card, PLAY_RESULTS['si-cf'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.single_center += r_val[0]
|
||||
@ -1847,7 +1847,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
secondary = None
|
||||
|
||||
r_val = assign_bchances(card, PLAY_RESULTS['si*'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.single_one += r_val[0]
|
||||
@ -1882,7 +1882,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
secondary = None
|
||||
|
||||
r_val = assign_bchances(card, PLAY_RESULTS['walk'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.walk += r_val[0]
|
||||
@ -1902,7 +1902,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_bchances(card, PLAY_RESULTS['bp-si'], ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.bp_single += r_val[0]
|
||||
@ -1914,7 +1914,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
full_log(new_ratings, card)
|
||||
r_val = assign_bchances(
|
||||
card, PlayResult(full_name=f'lo ({pref_mif}) max', short_name=f'lo ({pref_mif}) max'), Decimal(1))
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
data.lineout -= r_val[0]
|
||||
new_ratings.lineout += r_val[0]
|
||||
@ -1933,7 +1933,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
PlayResult(full_name=f'popout ({this_if})', short_name=f'popout ({this_if})'),
|
||||
Decimal(math.floor(ch))
|
||||
)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
if r_val[0] == 0:
|
||||
data.lineout += res_chances
|
||||
@ -1952,7 +1952,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_bchances(
|
||||
card, PlayResult(full_name=f'fly (cf) A', short_name=f'fly (cf) A'), Decimal(math.floor(ch)))
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
if r_val[0] == 0:
|
||||
data.strikeout += res_chances if data.strikeout > 2 else 0
|
||||
@ -1971,7 +1971,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_bchances(
|
||||
card, PlayResult(full_name=f'fly (lf) B', short_name=f'fly (lf) B'), Decimal(math.floor(ch)))
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
if r_val[0] == 0:
|
||||
data.strikeout += res_chances if data.strikeout > 2 else 0
|
||||
@ -1990,7 +1990,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_bchances(
|
||||
card, PlayResult(full_name=f'fly (rf) B', short_name=f'fly (rf) B'), Decimal(math.floor(ch)))
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
if r_val[0] == 0:
|
||||
data.strikeout += res_chances if data.strikeout > 2 else 0
|
||||
@ -2024,7 +2024,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
r_val = assign_bchances(
|
||||
card, PlayResult(full_name=f'gb ({this_if}) A', short_name=f'gb ({this_if}) A'),
|
||||
Decimal(math.floor(ch)))
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
if r_val[0] == 0:
|
||||
data.groundout_b += res_chances
|
||||
@ -2046,7 +2046,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
r_val = assign_bchances(
|
||||
card, PlayResult(full_name=f'gb ({this_if}) B', short_name=f'gb ({this_if}) B'),
|
||||
Decimal(math.floor(ch)))
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
if r_val[0] == 0:
|
||||
data.groundout_c += res_chances
|
||||
@ -2068,7 +2068,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
r_val = assign_bchances(
|
||||
card, PlayResult(full_name=f'gb ({this_if}) C', short_name=f'gb ({this_if}) C'),
|
||||
Decimal(math.floor(ch)))
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
if r_val[0] == 0:
|
||||
data.strikeout += res_chances
|
||||
@ -2091,7 +2091,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
PlayResult(full_name=f'lineout ({this_if})', short_name=f'lineout ({this_if})'),
|
||||
Decimal(math.floor(ch))
|
||||
)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
if r_val[0] == 0:
|
||||
break
|
||||
@ -2109,7 +2109,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_bchances(
|
||||
card, PlayResult(full_name=f'strikeout', short_name=f'strikeout'), Decimal(math.floor(ch)))
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
if r_val[0] == 0:
|
||||
break
|
||||
@ -2140,9 +2140,9 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
else:
|
||||
play_res = PlayResult(full_name=f'popout (c)', short_name=f'popout (c)')
|
||||
|
||||
logging.info(f'Send Card Fill\n{play_res}')
|
||||
logging.debug(f'Send Card Fill\n{play_res}')
|
||||
r_val = card.card_fill(play_res)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
if this_play[1] == 'so':
|
||||
new_ratings.strikeout += r_val[0]
|
||||
@ -2161,8 +2161,8 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
vl_output = vl.card_output()
|
||||
vr_output = vr.card_output()
|
||||
|
||||
logging.info(f'vl: {vl.sample_output()}')
|
||||
logging.info(f'vr: {vr.sample_output()}')
|
||||
logging.debug(f'vl: {vl.sample_output()}')
|
||||
logging.debug(f'vr: {vr.sample_output()}')
|
||||
|
||||
vl_total = new_battingratings[0].total_chances()
|
||||
vr_total = new_battingratings[1].total_chances()
|
||||
@ -2243,7 +2243,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
def assign_pchances(
|
||||
this_card: FullPitchingCard, play: PlayResult, chances: Decimal,
|
||||
secondary_play: Optional[PlayResult] = None):
|
||||
logging.info(f'Assign pitching chances\n{play}\nChances: {chances}\nBackup: {secondary_play}')
|
||||
logging.debug(f'Assign pitching chances\n{play}\nChances: {chances}\nBackup: {secondary_play}')
|
||||
r_data = this_card.add_result(play, chances, secondary_play)
|
||||
if r_data:
|
||||
return r_data
|
||||
@ -2292,17 +2292,17 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
while res_chances > 0:
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PLAY_RESULTS['bp-hr'], ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.bp_homerun += r_val[0]
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.hbp
|
||||
while res_chances > 0:
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PlayResult(full_name='HBP', short_name='HBP'), ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.hbp += r_val[0]
|
||||
@ -2310,97 +2310,97 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
break
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.xcheck_p
|
||||
while res_chances > 0:
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PlayResult(full_name=f'gb (p) X', short_name=f'gb (p) X'), ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.xcheck_p += r_val[0]
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.xcheck_c
|
||||
while res_chances > 0:
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PlayResult(full_name=f'catch X', short_name=f'catch X'), ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.xcheck_c += r_val[0]
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.xcheck_1b
|
||||
while res_chances > 0:
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PlayResult(full_name=f'gb (1b) X', short_name=f'gb (1b) X'), ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.xcheck_1b += r_val[0]
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.xcheck_3b
|
||||
while res_chances > 0:
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PlayResult(full_name=f'gb (3b) X', short_name=f'gb (3b) X'), ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.xcheck_3b += r_val[0]
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.xcheck_rf
|
||||
while res_chances > 0:
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PlayResult(full_name=f'fly (rf) X', short_name=f'fly (rf) X'), ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.xcheck_rf += r_val[0]
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.xcheck_lf
|
||||
while res_chances > 0:
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PlayResult(full_name=f'fly (lf) X', short_name=f'fly (lf) X'), ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.xcheck_lf += r_val[0]
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.xcheck_2b
|
||||
while res_chances > 0:
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PlayResult(full_name=f'gb (2b) X', short_name=f'gb (2b) X'), ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.xcheck_2b += r_val[0]
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.xcheck_cf
|
||||
while res_chances > 0:
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PlayResult(full_name=f'fly (cf) X', short_name=f'fly (cf) X'), ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.xcheck_cf += r_val[0]
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.xcheck_ss
|
||||
while res_chances > 0:
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PlayResult(full_name=f'gb (ss) X', short_name=f'gb (ss) X'), ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.xcheck_ss += r_val[0]
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.walk
|
||||
while res_chances >= 1:
|
||||
ch = get_chances(res_chances)
|
||||
@ -2410,7 +2410,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
secondary = None
|
||||
|
||||
r_val = assign_pchances(card, PLAY_RESULTS['walk'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.walk += r_val[0]
|
||||
@ -2421,7 +2421,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
break
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.homerun
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2461,7 +2461,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
secondary = None
|
||||
|
||||
r_val = assign_pchances(card, PLAY_RESULTS['hr'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.homerun += r_val[0]
|
||||
@ -2491,7 +2491,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
retries += 1
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.triple
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2527,7 +2527,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
secondary = None
|
||||
|
||||
r_val = assign_pchances(card, PLAY_RESULTS['tr'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.triple += r_val[0]
|
||||
@ -2557,7 +2557,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
retries += 1
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.double_three
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2591,7 +2591,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
secondary = None
|
||||
|
||||
r_val = assign_pchances(card, PLAY_RESULTS['do***'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.double_three += r_val[0]
|
||||
@ -2618,7 +2618,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
retries += 1
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.double_cf
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2648,7 +2648,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
secondary = None
|
||||
|
||||
r_val = assign_pchances(card, PLAY_RESULTS[f'do-cf'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.double_cf += r_val[0]
|
||||
@ -2675,7 +2675,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
retries += 1
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.double_two
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2705,7 +2705,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
secondary = None
|
||||
|
||||
r_val = assign_pchances(card, PLAY_RESULTS['do**'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.double_two += r_val[0]
|
||||
@ -2726,7 +2726,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
retries += 1
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.single_two
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2757,7 +2757,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
secondary = None
|
||||
|
||||
r_val = assign_pchances(card, PLAY_RESULTS['si**'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.single_two += r_val[0]
|
||||
@ -2780,7 +2780,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
retries += 1
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.single_center
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2804,7 +2804,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
secondary = None
|
||||
|
||||
r_val = assign_pchances(card, PLAY_RESULTS['si-cf'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.single_center += r_val[0]
|
||||
@ -2822,7 +2822,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
retries += 1
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.single_one
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2843,7 +2843,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
secondary = None
|
||||
|
||||
r_val = assign_pchances(card, PLAY_RESULTS['si*'], ch, secondary)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.single_one += r_val[0]
|
||||
@ -2858,7 +2858,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
retries += 1
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.bp_single
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2866,7 +2866,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
break
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PLAY_RESULTS['bp-si'], ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.bp_single += r_val[0]
|
||||
@ -2874,7 +2874,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
retries += 1
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.strikeout
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2882,7 +2882,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
break
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PlayResult(full_name=f'strikeout', short_name=f'so'), ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.strikeout += r_val[0]
|
||||
@ -2890,7 +2890,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
retries += 1
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.flyout_cf_b
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2898,7 +2898,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
break
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PLAY_RESULTS['fly-cf'], ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.flyout_cf_b += r_val[0]
|
||||
@ -2906,7 +2906,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
retries += 1
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.flyout_lf_b
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2914,7 +2914,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
break
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PLAY_RESULTS['fly-lf'], ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.flyout_lf_b += r_val[0]
|
||||
@ -2922,7 +2922,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
retries += 1
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.flyout_rf_b
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2930,7 +2930,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
break
|
||||
ch = get_chances(res_chances)
|
||||
r_val = assign_pchances(card, PLAY_RESULTS['fly-rf'], ch)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.flyout_rf_b += r_val[0]
|
||||
@ -2938,7 +2938,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
retries += 1
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.groundout_a
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2953,7 +2953,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
PlayResult(full_name=f'gb ({pref_mif}) A', short_name=f'gb ({pref_mif}) A'),
|
||||
ch
|
||||
)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.groundout_a += r_val[0]
|
||||
@ -2961,7 +2961,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
if r_val[0] == 0:
|
||||
retries += 1
|
||||
|
||||
full_log(new_ratings, card, info=True)
|
||||
full_log(new_ratings, card)
|
||||
res_chances = data.groundout_b
|
||||
retries = 0
|
||||
while res_chances > 0:
|
||||
@ -2975,7 +2975,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
PlayResult(full_name=f'gb ({pref_mif}) B', short_name=f'gb ({pref_mif}) B'),
|
||||
ch
|
||||
)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
res_chances -= r_val[0]
|
||||
new_ratings.groundout_b += r_val[0]
|
||||
@ -3005,9 +3005,9 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
else:
|
||||
play_res = PLAY_RESULTS['fly-rf']
|
||||
|
||||
logging.info(f'Send Card Fill\n{play_res}')
|
||||
logging.debug(f'Send Card Fill\n{play_res}')
|
||||
r_val = card.card_fill(play_res)
|
||||
logging.info(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
logging.debug(f'Returned batting chances: {r_val[0]} / {r_val[1]}\n')
|
||||
|
||||
if this_play[1] == 'so':
|
||||
new_ratings.strikeout += r_val[0]
|
||||
@ -3027,8 +3027,8 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
vl_output = vl.card_output()
|
||||
vr_output = vr.card_output()
|
||||
|
||||
logging.info(f'vl: {vl.sample_output()}')
|
||||
logging.info(f'vr: {vr.sample_output()}')
|
||||
logging.debug(f'vl: {vl.sample_output()}')
|
||||
logging.debug(f'vr: {vr.sample_output()}')
|
||||
|
||||
vl_total = new_pitchingratings[0].total_chances()
|
||||
vr_total = new_pitchingratings[1].total_chances()
|
||||
|
||||
@ -171,30 +171,8 @@ def get_scouting_dfs(cardset_id: list = None):
|
||||
db.close()
|
||||
|
||||
bat_df = pd.merge(vl, vr, on='player_id', suffixes=('_vl', '_vr')).set_index('player_id', drop=False)
|
||||
# output['Range P'] = ''
|
||||
# output['Range C'] = ''
|
||||
# output['Range 1B'] = ''
|
||||
# output['Range 2B'] = ''
|
||||
# output['Range 3B'] = ''
|
||||
# output['Range SS'] = ''
|
||||
# output['Range LF'] = ''
|
||||
# output['Range CF'] = ''
|
||||
# output['Range RF'] = ''
|
||||
# output['Error P'] = ''
|
||||
# output['Error C'] = ''
|
||||
# output['Error 1B'] = ''
|
||||
# output['Error 2B'] = ''
|
||||
# output['Error 3B'] = ''
|
||||
# output['Error SS'] = ''
|
||||
# output['Error LF'] = ''
|
||||
# output['Error CF'] = ''
|
||||
# output['Error RF'] = ''
|
||||
# output['Arm C'] = ''
|
||||
# output['Throw C'] = ''
|
||||
# output['PB C'] = ''
|
||||
# output['Arm OF'] = ''
|
||||
|
||||
logging.info(f'bat_df: {bat_df}')
|
||||
logging.debug(f'bat_df: {bat_df}')
|
||||
|
||||
positions = CardPosition.select()
|
||||
if cardset_id is not None:
|
||||
@ -211,14 +189,6 @@ def get_scouting_dfs(cardset_id: list = None):
|
||||
dict([(x.player.player_id, x.error) for x in positions.where(CardPosition.position == pos_code)]),
|
||||
name=f'Error {pos_code}'
|
||||
))
|
||||
# bat_df.join(pd.Series(
|
||||
# dict([(x.player.player_id, x.range) for x in positions.where(CardPosition.position == pos_code)]),
|
||||
# name=f'Range {pos_code}'
|
||||
# ))
|
||||
# bat_df.join(pd.Series(
|
||||
# dict([(x.player.player_id, x.error) for x in positions.where(CardPosition.position == pos_code)]),
|
||||
# name=f'Error {pos_code}'
|
||||
# ))
|
||||
|
||||
series_list.append(pd.Series(
|
||||
dict([(x.player.player_id, x.arm) for x in positions.where(CardPosition.position << ['LF', 'CF', 'RF'])]),
|
||||
@ -237,18 +207,7 @@ def get_scouting_dfs(cardset_id: list = None):
|
||||
name=f'Throw C'
|
||||
))
|
||||
|
||||
logging.info(f'series_list: {series_list}')
|
||||
|
||||
# for x in positions:
|
||||
# if x.position != 'DH':
|
||||
# output.at[f'{x.player.player_id}', f'Range {x.position}'] = x.range # vals in .at list are reversed
|
||||
# output.at[f'{x.player.player_id}', f'Error {x.position}'] = x.error
|
||||
# if x.position in ['LF', 'CF', 'RF']:
|
||||
# output.at[f'{x.player.player_id}', f'Arm OF'] = x.arm
|
||||
# if x.position == 'C':
|
||||
# output.at[f'{x.player.player_id}', f'Arm C'] = x.arm
|
||||
# output.at[f'{x.player.player_id}', f'PB C'] = x.pb
|
||||
# output.at[f'{x.player.player_id}', f'Throw C'] = x.overthrow
|
||||
logging.debug(f'series_list: {series_list}')
|
||||
|
||||
return bat_df.join(series_list)
|
||||
|
||||
@ -304,7 +263,7 @@ async def get_card_scouting(team_id: int, ts: str, cardset_id: list = Query(defa
|
||||
@router.get('/basic')
|
||||
async def get_basic_scouting(cardset_id: list = Query(default=None)):
|
||||
raw_data = get_scouting_dfs(cardset_id)
|
||||
logging.info(f'output: {raw_data}')
|
||||
logging.debug(f'output: {raw_data}')
|
||||
|
||||
def get_raw_speed(df_data):
|
||||
speed_raw = df_data['running'] / 20 + df_data['steal_jump']
|
||||
|
||||
@ -77,7 +77,7 @@ async def get_cards(
|
||||
if dupes:
|
||||
if team_id is None:
|
||||
raise HTTPException(status_code=400, detail='Dupe checking must include a team_id')
|
||||
logging.info(f'dupe check')
|
||||
logging.debug(f'dupe check')
|
||||
p_query = Card.select(Card.player).where(Card.team_id == team_id)
|
||||
seen = set()
|
||||
dupes = []
|
||||
|
||||
@ -436,7 +436,7 @@ async def get_batter_card(
|
||||
(PitchingCardRatings.id == rating_vr.id)
|
||||
).execute()
|
||||
|
||||
logging.info(f'Rating updates: {updates}')
|
||||
logging.debug(f'Rating updates: {updates}')
|
||||
|
||||
hti = Html2Image(
|
||||
browser='chromium',
|
||||
@ -644,12 +644,12 @@ async def put_players(players: PlayerModel, token: str = Depends(oauth2_scheme))
|
||||
'description': x.description
|
||||
})
|
||||
|
||||
logging.info(f'new_players: {new_players}')
|
||||
logging.debug(f'new_players: {new_players}')
|
||||
|
||||
with db.atomic():
|
||||
# Player.bulk_create(new_players, batch_size=15)
|
||||
for batch in chunked(new_players, 15):
|
||||
logging.info(f'batch: {batch}')
|
||||
logging.debug(f'batch: {batch}')
|
||||
Player.insert_many(batch).on_conflict_replace().execute()
|
||||
db.close()
|
||||
|
||||
|
||||
@ -486,8 +486,8 @@ async def get_batting_totals(
|
||||
limit = 500
|
||||
bat_plays = bat_plays.paginate(page_num, limit)
|
||||
|
||||
logging.info(f'bat_plays query: {bat_plays}')
|
||||
logging.info(f'run_plays query: {run_plays}')
|
||||
logging.debug(f'bat_plays query: {bat_plays}')
|
||||
logging.debug(f'run_plays query: {run_plays}')
|
||||
|
||||
return_stats = {
|
||||
'count': bat_plays.count(),
|
||||
@ -589,7 +589,9 @@ async def get_batting_totals(
|
||||
x['player_cardset'] = x['player']['cardset']['name']
|
||||
x['team_id'] = x['team']['id']
|
||||
x['team_abbrev'] = x['team']['abbrev']
|
||||
del x['player'], x['team']
|
||||
x['game_id'] = x['game']['id']
|
||||
x['game_type'] = x['game']['game_type']
|
||||
del x['player'], x['team'], x['game']
|
||||
|
||||
output = pd.DataFrame(return_vals)
|
||||
first = ['player_id', 'player_name', 'player_cardset', 'team_id', 'team_abbrev']
|
||||
@ -928,7 +930,7 @@ async def get_game_summary(
|
||||
're24': x.sum_re24 * -1
|
||||
} for x in top_pitchers]
|
||||
top_players = [*top_b, *top_p]
|
||||
logging.info(f'top_players: {top_players}')
|
||||
logging.debug(f'top_players: {top_players}')
|
||||
|
||||
bot_players = [
|
||||
{
|
||||
|
||||
@ -181,9 +181,9 @@ async def get_team_lineup(team_id: int, difficulty_name: str, pitcher_name: str,
|
||||
else:
|
||||
backup_players = None
|
||||
|
||||
logging.info(f'legal_players: {legal_players.count()}')
|
||||
logging.debug(f'legal_players: {legal_players.count()}')
|
||||
if backup_players is not None:
|
||||
logging.info(f'backup_players: {backup_players.count()}')
|
||||
logging.debug(f'backup_players: {backup_players.count()}')
|
||||
player_names = []
|
||||
starting_nine = {
|
||||
'C': {'player': None, 'vl': None, 'vr': None, 'ops': 0},
|
||||
@ -221,17 +221,17 @@ async def get_team_lineup(team_id: int, difficulty_name: str, pitcher_name: str,
|
||||
# if x.battingcard.player.p_name not in player_names:
|
||||
# starting_nine['DH'] = x.battingcard.player
|
||||
# break
|
||||
logging.info(f'Searching for a DH!')
|
||||
logging.debug(f'Searching for a DH!')
|
||||
dh_query = legal_players.order_by(Player.cost.desc())
|
||||
for x in dh_query:
|
||||
logging.info(f'checking {x.p_name} for {position}')
|
||||
logging.debug(f'checking {x.p_name} for {position}')
|
||||
if x.p_name not in player_names and 'P' not in x.pos_1:
|
||||
logging.info(f'adding!')
|
||||
logging.debug(f'adding!')
|
||||
starting_nine['DH']['player'] = model_to_dict(x)
|
||||
try:
|
||||
vl, vr, total_ops = get_bratings(x.player_id)
|
||||
except AttributeError as e:
|
||||
logging.info(f'Could not find batting lines')
|
||||
logging.debug(f'Could not find batting lines')
|
||||
else:
|
||||
starting_nine['DH']['vl'] = vl
|
||||
starting_nine['DH']['vr'] = vr
|
||||
@ -242,14 +242,14 @@ async def get_team_lineup(team_id: int, difficulty_name: str, pitcher_name: str,
|
||||
if starting_nine['DH']['player'] is None:
|
||||
dh_query = backup_players.order_by(Player.cost.desc())
|
||||
for x in dh_query:
|
||||
logging.info(f'checking {x.p_name} for {position}')
|
||||
logging.debug(f'checking {x.p_name} for {position}')
|
||||
if x.p_name not in player_names:
|
||||
logging.info(f'adding!')
|
||||
logging.debug(f'adding!')
|
||||
starting_nine['DH']['player'] = model_to_dict(x)
|
||||
try:
|
||||
vl, vr, total_ops = get_bratings(x.player_id)
|
||||
except AttributeError as e:
|
||||
logging.info(f'Could not find batting lines')
|
||||
logging.debug(f'Could not find batting lines')
|
||||
else:
|
||||
vl, vr, total_ops = get_bratings(x.player_id)
|
||||
starting_nine['DH']['vl'] = vl
|
||||
@ -274,12 +274,12 @@ async def get_team_lineup(team_id: int, difficulty_name: str, pitcher_name: str,
|
||||
elif d_rank == 8:
|
||||
pos_group = pos_group.order_by(CardPosition.error.desc())
|
||||
|
||||
logging.info(f'pos_group: {pos_group}\n{starting_nine}\n{player_names}\n\n')
|
||||
logging.debug(f'pos_group: {pos_group}\n{starting_nine}\n{player_names}\n\n')
|
||||
if difficulty_name in ['minor-league', 'gauntlet-3']:
|
||||
for x in pos_group:
|
||||
logging.info(f'checking {x.player.p_name} for {position}')
|
||||
logging.debug(f'checking {x.player.p_name} for {position}')
|
||||
if x.player.p_name not in player_names and x.player.p_name.lower() != pitcher_name:
|
||||
logging.info(f'adding!')
|
||||
logging.debug(f'adding!')
|
||||
starting_nine[position]['player'] = model_to_dict(x.player)
|
||||
vl, vr, total_ops = get_bratings(x.player.player_id)
|
||||
starting_nine[position]['vl'] = vl
|
||||
@ -290,9 +290,9 @@ async def get_team_lineup(team_id: int, difficulty_name: str, pitcher_name: str,
|
||||
|
||||
if starting_nine[position]['player'] is None:
|
||||
for x in backup_group:
|
||||
logging.info(f'checking {x.player.p_name} for {position}')
|
||||
logging.debug(f'checking {x.player.p_name} for {position}')
|
||||
if x.player.p_name not in player_names and x.player.p_name.lower() != pitcher_name:
|
||||
logging.info(f'adding!')
|
||||
logging.debug(f'adding!')
|
||||
starting_nine[position]['player'] = model_to_dict(x.player)
|
||||
vl, vr, total_ops = get_bratings(x.player.player_id)
|
||||
starting_nine[position]['vl'] = vl
|
||||
@ -349,7 +349,7 @@ def sort_pitchers(pitching_card_query) -> DataFrame | None:
|
||||
return None
|
||||
|
||||
pitcher_df = pd.DataFrame(all_s).set_index('player', drop=False)
|
||||
logging.info(f'pitcher_df: {pitcher_df}')
|
||||
logging.debug(f'pitcher_df: {pitcher_df}')
|
||||
|
||||
def get_total_ops(df_data):
|
||||
vlval = PitchingCardRatings.get_or_none(
|
||||
@ -639,7 +639,7 @@ async def team_buy_players(team_id: int, ids: str, ts: str):
|
||||
|
||||
# check wallet balance
|
||||
if this_team.wallet < this_player.cost:
|
||||
logging.info(f'{this_player} was not purchased. {this_team.lname} only has {this_team.wallet}₼, but '
|
||||
logging.error(f'{this_player} was not purchased. {this_team.lname} only has {this_team.wallet}₼, but '
|
||||
f'{this_player} costs {this_player.cost}₼.')
|
||||
db.close()
|
||||
raise HTTPException(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user