From 8c589de8f4036c241d427388c205a40b9792191e Mon Sep 17 00:00:00 2001 From: miztch Date: Thu, 13 Jun 2024 16:07:24 +0000 Subject: [PATCH 1/3] feat: add startDate attribute to use as sort key --- functions/sasha/index.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/sasha/index.py b/functions/sasha/index.py index a89b612..ab385e6 100644 --- a/functions/sasha/index.py +++ b/functions/sasha/index.py @@ -108,6 +108,7 @@ def scrape_match(match_url_path): start_time_est = parse(with_timezone, tzinfos=tzinfo) start_time_utc = start_time_est.astimezone(tz.gettz("Etc/GMT")) start_time_utc = datetime.strftime(start_time_utc, "%Y-%m-%dT%H:%M:%S%z") + start_date_utc = datetime.strftime(start_time_utc, "%Y-%m-%d") teams = html.css(".wf-title-med") teams = [t.text().replace("\t", "").replace("\n", "") for t in teams] @@ -128,6 +129,7 @@ def scrape_match(match_url_path): data = { "match_id": match_id, + "start_date": start_date_utc, "event_name": event_info["event_name"], "event_country_flag": event_info["country_flag"], "start_time": start_time_utc, @@ -159,6 +161,7 @@ def scrape_matches(page: str = 1): item = { "id": match_detail["match_id"], + "startDate": match_detail["start_date"], "eventName": match_detail["event_name"], "eventCountryFlag": match_detail["event_country_flag"], "startTime": match_detail["start_time"], From ca2362166d3dc0ef680c4dfa305f616bd9ca242c Mon Sep 17 00:00:00 2001 From: miztch Date: Thu, 13 Jun 2024 16:07:58 +0000 Subject: [PATCH 2/3] feat: add sort key to match table --- template.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/template.yaml b/template.yaml index df3c00c..4316310 100644 --- a/template.yaml +++ b/template.yaml @@ -119,11 +119,15 @@ Resources: AttributeDefinitions: - AttributeName: id AttributeType: N + - AttributeName: startDate + AttributeType: S BillingMode: PROVISIONED DeletionProtectionEnabled: True KeySchema: - AttributeName: id KeyType: HASH + - AttributeName: startDate + KeyType: RANGE ProvisionedThroughput: ReadCapacityUnits: 1 WriteCapacityUnits: 1 From addb1a265498f943a99c93dedb58cc153bcfd69e Mon Sep 17 00:00:00 2001 From: miztch Date: Thu, 13 Jun 2024 16:17:44 +0000 Subject: [PATCH 3/3] fix: type --- functions/sasha/index.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/sasha/index.py b/functions/sasha/index.py index ab385e6..8e96d5f 100644 --- a/functions/sasha/index.py +++ b/functions/sasha/index.py @@ -105,10 +105,10 @@ def scrape_match(match_url_path): with_timezone = " ".join([start_time, "EST"]) tzinfo = {"EST": tz.gettz("America/New_York"), "CST": tz.gettz("America/Chicago")} - start_time_est = parse(with_timezone, tzinfos=tzinfo) - start_time_utc = start_time_est.astimezone(tz.gettz("Etc/GMT")) - start_time_utc = datetime.strftime(start_time_utc, "%Y-%m-%dT%H:%M:%S%z") - start_date_utc = datetime.strftime(start_time_utc, "%Y-%m-%d") + dt_start_time_est = parse(with_timezone, tzinfos=tzinfo) + dt_start_time_utc = dt_start_time_est.astimezone(tz.gettz("Etc/GMT")) + start_time_utc = datetime.strftime(dt_start_time_utc, "%Y-%m-%dT%H:%M:%S%z") + start_date_utc = datetime.strftime(dt_start_time_utc, "%Y-%m-%d") teams = html.css(".wf-title-med") teams = [t.text().replace("\t", "").replace("\n", "") for t in teams]