Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize agg queries #36

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion open_bus_stride_api/routers/gtfs_rides_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ def list_(limit: int = common.param_limit(default_limit=DEFAULT_LIMIT),
where
agg.gtfs_route_id = rt.id
and agg.gtfs_route_date >= :date_from
and agg.gtfs_route_date <= :date_to
and agg.gtfs_route_date <= :date_to
and rt.date >= :rt_date_from
and rt.date <= :rt_date_to
"""
sql_params = {
'date_from': date_from,
'date_to': date_to,
'rt_date_from': date_from - datetime.timedelta(days=1),
'rt_date_to': date_from + datetime.timedelta(days=1),
}

if exclude_hours_from:
Expand Down Expand Up @@ -116,10 +120,14 @@ def group_by_(date_from: datetime.date = common.doc_param('date', filter_type='d
agg.gtfs_route_id = rt.id
and agg.gtfs_route_date >= :date_from
and agg.gtfs_route_date <= :date_to
and rt.date >= :rt_date_from
and rt.date <= :rt_date_to
""")
sql_params = {
'date_from': date_from,
'date_to': date_to,
'rt_date_from': date_from - datetime.timedelta(days=1),
'rt_date_to': date_from + datetime.timedelta(days=1),
}

if exclude_hours_from:
Expand Down
Loading