Skip to content

Commit

Permalink
Fix processing for ridership chart
Browse files Browse the repository at this point in the history
  • Loading branch information
devinmatte committed Jan 9, 2025
1 parent 1232833 commit 2894a07
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ingestor/chalicelib/landing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import boto3
from boto3.dynamodb.conditions import Key
from chalicelib import s3
Expand Down Expand Up @@ -45,7 +46,7 @@ def get_ridership_data():
ridership_object[line] = data

# get data for commuter rail (treated as one line)
ridership_object["line-commuter-rail"] = [None] * 10
ridership_object["line-commuter-rail"] = [None] * (len(data) - 1)
for line in constants.COMMUTER_RAIL_LINES:
data = query_landing_ridership_data(constants.commuter_rail_ridership_key(line))
for index, week in enumerate(data):
Expand Down Expand Up @@ -85,3 +86,13 @@ def upload_to_s3(trip_metrics, ridership):
def clear_cache():
for distribution in DISTRIBUTIONS:
s3.clear_cf_cache(distribution, ["/static/landing/*"])


if __name__ == "__main__":
print(
f"Uploading ridership and trip metric data for landing page from {constants.NINETY_DAYS_AGO_STRING} to {constants.ONE_WEEK_AGO_STRING}"
)
trip_metrics_data = get_trip_metrics_data()
ridership_data = get_ridership_data()
upload_to_s3(json.dumps(trip_metrics_data), json.dumps(ridership_data))
clear_cache()

0 comments on commit 2894a07

Please sign in to comment.