From 5a740e8a2ce3dabcd19a5d435266b5e2c9b45b28 Mon Sep 17 00:00:00 2001 From: Devin Matte Date: Sat, 25 Jan 2025 14:02:58 -0500 Subject: [PATCH 1/2] Track Mattapan data --- ingestor/chalicelib/agg_speed_tables.py | 4 ++-- ingestor/chalicelib/constants.py | 22 +++++++++++++++++++++- ingestor/chalicelib/daily_speeds.py | 2 +- ingestor/chalicelib/stations.py | 17 +++++++++++++++-- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/ingestor/chalicelib/agg_speed_tables.py b/ingestor/chalicelib/agg_speed_tables.py index 388d78e..7d78868 100644 --- a/ingestor/chalicelib/agg_speed_tables.py +++ b/ingestor/chalicelib/agg_speed_tables.py @@ -17,7 +17,7 @@ @dataclass class Line: - Literal["line-red", "line-orange", "line-blue", "line-green"] + Literal["line-red", "line-orange", "line-blue", "line-green", "line-mattapan"] @dataclass @@ -99,7 +99,7 @@ def actual_trips_by_line(params: TripsByLineParams): start_date = params["start_date"] end_date = params["end_date"] line = params["line"] - if line not in ["line-red", "line-blue", "line-green", "line-orange"]: + if line not in ["line-red", "line-blue", "line-green", "line-orange", "line-mattapan"]: raise BadRequestError("Invalid Line key.") except KeyError: raise BadRequestError("Missing or invalid parameters.") diff --git a/ingestor/chalicelib/constants.py b/ingestor/chalicelib/constants.py index 18e9267..6ab745d 100644 --- a/ingestor/chalicelib/constants.py +++ b/ingestor/chalicelib/constants.py @@ -11,6 +11,7 @@ ("line-green", "c"), ("line-green", "d"), ("line-green", "e"), + ("line-mattapan", None), ] ALL_LINES: list[str] = ["Red", "Orange", "Blue", "Green-B", "Green-C", "Green-D", "Green-E", "Mattapan"] STATIONS = stations.STATIONS @@ -228,6 +229,23 @@ }, }, }, + "line-mattapan": { + "line": "line-mattapan", + "route": None, + "excluding_terminals": { + "stops": [ + [STATIONS["CAPEN_ST"]["NB"], STATIONS["CEDAR_GROVE"]["NB"]], + [STATIONS["CEDAR_GROVE"]["SB"], STATIONS["CAPEN_ST"]["SB"]], + ], + "length": Decimal("2.55") * 2, + }, + "including_terminals": { + "stops": [ + [STATIONS["ASHMONT"]["NB"], STATIONS["MATTAPAN"]["NB"]], + [STATIONS["MATTAPAN"]["SB"], STATIONS["ASHMONT"]["SB"]], + ], + }, + }, } @@ -242,12 +260,13 @@ def get_route_metadata(line: str, date: date, include_terminals: bool, route: st return TERMINI_NEW[line][terminals_key] -LINES: list[str] = ["line-red", "line-orange", "line-blue", "line-green"] +LINES: list[str] = ["line-red", "line-orange", "line-blue", "line-green", "line-mattapan"] RIDERSHIP_KEYS = { "line-red": "line-Red", "line-orange": "line-Orange", "line-blue": "line-Blue", "line-green": "line-Green", + "line-mattapan": "line-Mattapan", } COMMUTER_RAIL_LINES = [ "CR-Fairmount", @@ -317,4 +336,5 @@ def get_weekly_table_update_start(): "line-green": ["line-green-b", "line-green-c", "line-green-d", "line-green-e"], "line-blue": ["line-blue"], "line-orange": ["line-orange"], + "line-mattapan": ["line-mattapan"], } diff --git a/ingestor/chalicelib/daily_speeds.py b/ingestor/chalicelib/daily_speeds.py index 3e535d9..3f6d3ca 100644 --- a/ingestor/chalicelib/daily_speeds.py +++ b/ingestor/chalicelib/daily_speeds.py @@ -102,7 +102,7 @@ def populate_daily_table(start_date: datetime, end_date: datetime, line: str, ro current_date = start_date.date() delta = timedelta(days=180) speed_objects = [] - while current_date < end_date: + while current_date < end_date.date(): route_metadata = constants.get_route_metadata(line, current_date, False, route) print(f"Calculating daily values for 180 day chunk starting at: {current_date}") API_requests = get_agg_tt_api_requests(route_metadata["stops"], current_date, delta) diff --git a/ingestor/chalicelib/stations.py b/ingestor/chalicelib/stations.py index 16d76b6..2a8ab57 100644 --- a/ingestor/chalicelib/stations.py +++ b/ingestor/chalicelib/stations.py @@ -5,8 +5,8 @@ "NB": 70061, }, "ASHMONT": { - "SB": 70093, - "NB": 70094, + "SB": (70093, 70261), + "NB": (70094, 70261), }, "BRAINTREE": { "SB": 70105, @@ -123,4 +123,17 @@ "SB": (70196, 70197, 70198, 70199), "NB": 70200, }, + # Mattapan LINE + "MATTAPAN": { + "SB": 70275, + "NB": 70276, + }, + "CAPEN_ST": { + "SB": 70273, + "NB": 70274, + }, + "CEDAR_GROVE": { + "SB": 70263, + "NB": 70264, + }, } From 9404b5a6d912f38fafa45d99bea2197d0914383a Mon Sep 17 00:00:00 2001 From: Devin Matte Date: Sat, 25 Jan 2025 15:53:04 -0500 Subject: [PATCH 2/2] Update codeowners --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 10791f5..a338814 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,3 @@ -* @austinjpaul @devinmatte +* @austinjpaul @devinmatte @transitmatters/labs-leads .github @devinmatte @nathan-weinberg devops @devinmatte @nathan-weinberg