Moved db statement to remove duplicate saves

This commit is contained in:
kevroded 2021-01-06 01:05:37 -05:00
parent 3c93d1e4c8
commit 97f125c55e

View File

@ -64,16 +64,18 @@ def update_loop():
if state["update_pause"] == 1: if state["update_pause"] == 1:
state["update_emoji"] = "🍿" state["update_emoji"] = "🍿"
if this_game.over: if this_game.over:
db.cache_history(this_game.teams['home'].name, this_game.teams["home"].score, this_game.teams['away'].name, this_game.teams['away'].score, this_game.weather.name)
state["display_inning"] -= 1 state["display_inning"] -= 1
state["display_top_of_inning"] = False state["display_top_of_inning"] = False
winning_team = this_game.teams['home'].name if this_game.teams['home'].score > this_game.teams['away'].score else this_game.teams['away'].name winning_team = this_game.teams['home'].name if this_game.teams['home'].score > this_game.teams['away'].score else this_game.teams['away'].name
if this_game.victory_lap and winning_team == this_game.teams['home'].name: if this_game.victory_lap and winning_team == this_game.teams['home'].name:
state["update_text"] = f"{winning_team} wins with a victory lap!" state["update_text"] = f"{winning_team} wins with a victory lap!"
db.cache_history(this_game.teams['home'].name, this_game.teams["home"].score, this_game.teams['away'].name, this_game.teams['away'].score, this_game.weather.name)
elif winning_team == this_game.teams['home'].name: elif winning_team == this_game.teams['home'].name:
state["update_text"] = f"{winning_team} wins, shaming {this_game.teams['away'].name}!" state["update_text"] = f"{winning_team} wins, shaming {this_game.teams['away'].name}!"
db.cache_history(this_game.teams['home'].name, this_game.teams["home"].score, this_game.teams['away'].name, this_game.teams['away'].score, this_game.weather.name)
else: else:
state["update_text"] = f"{winning_team} wins!" state["update_text"] = f"{winning_team} wins!"
db.cache_history(this_game.teams['home'].name, this_game.teams["home"].score, this_game.teams['away'].name, this_game.teams['away'].score, this_game.weather.name)
state["pitcher"] = "-" state["pitcher"] = "-"
state["batter"] = "-" state["batter"] = "-"
elif this_game.top_of_inning: elif this_game.top_of_inning: