Skip to content

Service Ridership Dashboard Service Summary

This page documents service summary functions in the Service Ridership Dashboard module.

ingestor.chalicelib.service_ridership_dashboard.service_summaries

summarize_weekly_service_around_date(date, service_levels)

Create a weekly service summary with breakdowns for weekday, Saturday, and Sunday.

Parameters:

Name Type Description Default
date date

The reference date to summarize service around.

required
service_levels ServiceLevelsByDate

A dictionary mapping dates to service level entries.

required

Returns:

Type Description
ServiceSummary

A ServiceSummary dict with weekday, Saturday, and Sunday service summaries.

Source code in ingestor/chalicelib/service_ridership_dashboard/service_summaries.py
def summarize_weekly_service_around_date(date: date, service_levels: ServiceLevelsByDate) -> ServiceSummary:
    """Create a weekly service summary with breakdowns for weekday, Saturday, and Sunday.

    Args:
        date: The reference date to summarize service around.
        service_levels: A dictionary mapping dates to service level entries.

    Returns:
        A ServiceSummary dict with weekday, Saturday, and Sunday service summaries.
    """
    weekday_service = _get_service_levels_summary_dict(
        service_levels=service_levels,
        start_lookback_date=date,
        matching_days_of_week=list(range(0, 5)),
    )
    saturday_service = _get_service_levels_summary_dict(
        service_levels=service_levels,
        start_lookback_date=date,
        matching_days_of_week=[5],
    )
    sunday_service = _get_service_levels_summary_dict(
        service_levels=service_levels,
        start_lookback_date=date,
        matching_days_of_week=[6],
    )
    return {
        "weekday": weekday_service,
        "saturday": saturday_service,
        "sunday": sunday_service,
    }