Service Ridership Dashboard Ingest¶
This page documents ingest functions in the Service Ridership Dashboard module.
ingestor.chalicelib.service_ridership_dashboard.ingest
¶
get_line_kind(route_ids, line_id)
¶
Determine the kind of transit line based on route IDs and line ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
route_ids
|
list[str]
|
A list of route identifiers associated with the line. |
required |
line_id
|
str
|
The MBTA line identifier. |
required |
Returns:
| Type | Description |
|---|---|
LineKind
|
The LineKind classification (e.g., "bus", "regional-rail", "red"). |
Source code in ingestor/chalicelib/service_ridership_dashboard/ingest.py
create_service_regimes(service_levels, date)
¶
Create service regime summaries for current, one year ago, and baseline periods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service_levels
|
ServiceLevelsByDate
|
A dictionary mapping dates to service level entries. |
required |
date
|
date
|
The reference date for computing service regimes. |
required |
Returns:
| Type | Description |
|---|---|
ServiceRegimes
|
A ServiceRegimes dict with current, oneYearAgo, and baseline summaries. |
Source code in ingestor/chalicelib/service_ridership_dashboard/ingest.py
create_line_data(start_date, end_date, service_levels, ridership)
¶
Build a LineData dictionary containing service and ridership history for a line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_date
|
date
|
The start date of the data range. |
required |
end_date
|
date
|
The end date of the data range. |
required |
service_levels
|
dict[date, ServiceLevelsEntry]
|
A dictionary mapping dates to service level entries for this line. |
required |
ridership
|
dict[date, RidershipEntry]
|
A dictionary mapping dates to ridership entries for this line. |
required |
Returns:
| Type | Description |
|---|---|
LineData
|
A LineData dict with line metadata, ridership history, service history, and regimes. |
Source code in ingestor/chalicelib/service_ridership_dashboard/ingest.py
create_service_ridership_dash_json(start_date=START_DATE, end_date=datetime.now(TIME_ZONE).date(), write_debug_files=False, write_to_s3=True, include_only_line_ids=None)
¶
Generate the complete service ridership dashboard JSON and optionally upload to S3.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_date
|
date
|
The start date for the dashboard data range. |
START_DATE
|
end_date
|
date
|
The end date for the dashboard data range. |
date()
|
write_debug_files
|
bool
|
Whether to write a local debug JSON file. |
False
|
write_to_s3
|
bool
|
Whether to upload the resulting JSON to S3. |
True
|
include_only_line_ids
|
Optional[list[str]]
|
If provided, only include these line IDs in the output. |
None
|
Source code in ingestor/chalicelib/service_ridership_dashboard/ingest.py
create_service_ridership_dash_json_command(start, end, debug=False, s3=False, lines=None)
¶
CLI command to create the service ridership dashboard JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
str
|
Start date string for the dashboard. |
required |
end
|
str
|
End date string for the dashboard. |
required |
debug
|
bool
|
Whether to write a local debug JSON file. |
False
|
s3
|
bool
|
Whether to upload the resulting JSON to S3. |
False
|
lines
|
Optional[str]
|
Comma-separated list of line names to include (without "line-" prefix). |
None
|