Skip to content

Commit

Permalink
Move boto3 calls within function.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdgsmallwood committed Jul 11, 2024
1 parent 159a25f commit b9b44a5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
load_dotenv()


dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("UVIndexTable")



def handler(event, context):
Expand Down Expand Up @@ -56,6 +55,9 @@ def get_previous_uv(uv: float) -> float:
If no previous value was logged for today - defaults to returning zero.
"""
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("UVIndexTable")

date_today = datetime.now(tz=timezone("Australia/Sydney")).strftime("%Y-%m-%d")
response = table.query(KeyConditionExpression=Key("date").eq(date_today))

Expand Down

0 comments on commit b9b44a5

Please sign in to comment.