Skip to content

Commit

Permalink
arrivals_departures/connections: expose trips.bikes_allowed ✅
Browse files Browse the repository at this point in the history
closes #60

Co-Authored-By: Jannis R <mail@jannisr.de>
  • Loading branch information
magnusburton and derhuerst committed Mar 11, 2024
1 parent a69397c commit df50320
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/stop_times.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ WITH stop_times_based AS NOT MATERIALIZED (
trips.direction_id,
trips.trip_headsign,
trips.wheelchair_accessible,
trips.bikes_allowed,
service_days.service_id,
trips.shape_id,
"date",
Expand Down Expand Up @@ -275,7 +276,7 @@ SELECT
-- todo: find a way to use all columns without explicitly enumerating them here
agency_id,
route_id, route_short_name, route_long_name, route_type,
trip_id, direction_id, trip_headsign, wheelchair_accessible,
trip_id, direction_id, trip_headsign, wheelchair_accessible, bikes_allowed,
service_id,
shape_id,
"date",
Expand Down Expand Up @@ -362,6 +363,7 @@ WITH stop_times_based AS NOT MATERIALIZED (
trips.direction_id,
trips.trip_headsign,
trips.wheelchair_accessible,
trips.bikes_allowed,
from_stop_id,
from_stop_name,
Expand Down Expand Up @@ -413,6 +415,7 @@ WITH stop_times_based AS NOT MATERIALIZED (
trips.direction_id,
trips.trip_headsign,
trips.wheelchair_accessible,
trips.bikes_allowed,
agency.agency_timezone,
from_stops.stop_id as from_stop_id,
Expand Down Expand Up @@ -517,6 +520,7 @@ SELECT
direction_id,
trip_headsign,
wheelchair_accessible,
bikes_allowed,
from_stop_id,
from_stop_name,
Expand Down
1 change: 1 addition & 0 deletions lib/trips.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CREATE TABLE "${opt.schema}".trips (
${opt.tripsWithoutShapeId ? '' : `CONSTRAINT valid_shape_id CHECK ("${opt.schema}".shape_exists(shape_id)),`}
-- todo [breaking]: use 0/unknown for empty values
wheelchair_accessible "${opt.schema}".wheelchair_accessibility,
-- todo [breaking]: use 0/unknown for empty values
bikes_allowed "${opt.schema}".bikes_allowance
);
Expand Down
21 changes: 21 additions & 0 deletions test/sample-gtfs-feed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,25 @@ if [[ "$wheelchair_accessible_arrs_deps_rows" != "$wheelchair_accessible_arrs_de
exit 1
fi
bikes_allowed_arrs_deps_query=$(cat << EOF
SELECT DISTINCT ON (trip_id)
trip_id, bikes_allowed
FROM arrivals_departures
WHERE route_id = ANY(ARRAY['A', 'B'])
ORDER BY trip_id
EOF)
bikes_allowed_arrs_deps_rows="$(psql --csv -t -c "$bikes_allowed_arrs_deps_query")"
bikes_allowed_arrs_deps_expected=$(cat << EOF
a-downtown-all-day,
a-outbound-all-day,
b-downtown-on-weekends,unknown
b-downtown-on-working-days,unknown
b-outbound-on-weekends,allowed
b-outbound-on-working-days,allowed
EOF)
if [[ "$bikes_allowed_arrs_deps_rows" != "$bikes_allowed_arrs_deps_expected" ]]; then
echo "arrivals_departures: invalid bikes_allowed values" 1>&2
exit 1
fi
echo 'works ✔'

0 comments on commit df50320

Please sign in to comment.