From 737a717bf16397ac6e7372dc943a90be299b14ed Mon Sep 17 00:00:00 2001 From: Matt Donders Date: Fri, 27 Sep 2019 22:55:53 -0400 Subject: [PATCH] Fixes minor home score issue and bad data for Final shotmap. --- lambda_trigger.py | 12 ++++++------ shotmaps_generator_sendtweet/lambda_handler.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lambda_trigger.py b/lambda_trigger.py index 472fbbc..a21be32 100644 --- a/lambda_trigger.py +++ b/lambda_trigger.py @@ -83,9 +83,14 @@ def trigger_lambda(game_id, lambda_arn, home_score, away_score): # Check game status game_state = livefeed["gameData"]["status"]["abstractGameState"] + # Get required attributes for lambda trigger + linescore = livefeed["liveData"]["linescore"] + home_score = linescore["teams"]["home"]["goals"] + away_score = linescore["teams"]["away"]["goals"] + if game_state == "Final": logging.info("Game is now final - send one final (end of game) shotmap & exit.") - lambda_response = trigger_lambda(game_id=game_id, lambda_arn=LAMBDA_ARN) + lambda_response = trigger_lambda(game_id=game_id, lambda_arn=LAMBDA_ARN, home_score=home_score, away_score=away_score) logging.info(lambda_response) sys.exit() @@ -94,11 +99,6 @@ def trigger_lambda(game_id, lambda_arn, home_score, away_score): time.sleep(SLEEP_TIME) continue - # Get required attributes for lambda trigger - linescore = livefeed["liveData"]["linescore"] - home_score = linescore["teams"]["home"]["goals"] - away_score = linescore["teams"]["away"]["goals"] - period = livefeed["liveData"]["linescore"]["currentPeriod"] period_ordinal = livefeed["liveData"]["linescore"]["currentPeriodOrdinal"] period_remain = livefeed["liveData"]["linescore"]["currentPeriodTimeRemaining"] diff --git a/shotmaps_generator_sendtweet/lambda_handler.py b/shotmaps_generator_sendtweet/lambda_handler.py index 1651ebf..3806286 100644 --- a/shotmaps_generator_sendtweet/lambda_handler.py +++ b/shotmaps_generator_sendtweet/lambda_handler.py @@ -221,7 +221,7 @@ def lambda_handler(event, context): if home_score == away_score: tweet_text = ( f"At the end of the {period_ordinal} period, the {home_team_short} & " - f"{away_team_short} are tied at 1." + f"{away_team_short} are tied at {home_score}." f"\n\n{game_hashtag}" )