Skip to content

Commit

Permalink
Typing.
Browse files Browse the repository at this point in the history
  • Loading branch information
bakert committed Nov 9, 2019
1 parent b803735 commit 1705189
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions decksite/data/match.py
Expand Up @@ -28,8 +28,8 @@ def insert_match(dt: datetime.datetime,
loser_id = left_id if left_games < right_games else right_id
db().begin('insert_match')
match_id = db().insert('INSERT INTO `match` (`date`, `round`, elimination, mtgo_id) VALUES (%s, %s, %s, %s)', [dtutil.dt2ts(dt), round_num, elimination, mtgo_match_id])
update_cache(left_id, left_games, right_games, active_date=dt)
update_cache(right_id, right_games, left_games, active_date=dt)
update_cache(left_id, left_games, right_games, dt=dt)
update_cache(right_id, right_games, left_games, dt=dt)
sql = 'INSERT INTO deck_match (deck_id, match_id, games) VALUES (%s, %s, %s)'
db().execute(sql, [left_id, match_id, left_games])
if right_id is not None: # Don't insert matches or adjust Elo for the bye.
Expand Down Expand Up @@ -148,7 +148,7 @@ def update_games(match_id: int, deck_id: int, games: int) -> int:
args = [games, match_id, deck_id]
return db().execute(sql, args)

def update_cache(deck_id: int, games: int, opponent_games: int, delete: Optional[bool] = False, active_date: Optional[datetime.datetime] = None) -> None:
def update_cache(deck_id: int, games: int, opponent_games: int, delete: Optional[bool] = False, dt: Optional[datetime.datetime] = None) -> None:
if games > opponent_games:
args = [1, 0, 0]
elif opponent_games > games:
Expand All @@ -157,7 +157,7 @@ def update_cache(deck_id: int, games: int, opponent_games: int, delete: Optional
args = [0, 0, 1]
args.append(deck_id)
symbol = '-' if delete else '+'
active_date = dtutil.dt2ts(active_date) if active_date else 'active_date'
active_date = dtutil.dt2ts(dt) if dt else 'active_date'
sql = f"""
UPDATE
deck_cache
Expand Down

0 comments on commit 1705189

Please sign in to comment.