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

Frequency based trips #828

Merged
merged 32 commits into from
Nov 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
582e8e3
ScheduleStopPair: add frequency_exact_times
irees Oct 17, 2016
abc2397
gtfs frequency lookup
irees Oct 18, 2016
80e87a4
Don't fail
irees Oct 19, 2016
43759f4
Migration: convert ScheduleStopPair.frequency_headway_seconds to integer
irees Oct 20, 2016
dc9bdf9
Annotations
irees Oct 20, 2016
4fc963d
Refactor to import frequencies
irees Oct 20, 2016
67fc984
Annotation [ci skip]
irees Oct 20, 2016
efb6d6a
SSP: add frequency to serializer
irees Oct 20, 2016
3692004
Spec fixin'
irees Oct 20, 2016
514207a
Don't generate trip_id with frequency details
irees Oct 26, 2016
cddc25c
Import frequency exact_times
irees Oct 26, 2016
54d9e67
Adjust migration - use frequency_type not frequency_exact_times
irees Oct 29, 2016
215cacb
Annotations
irees Oct 29, 2016
79d3b87
import frequency_type
irees Oct 29, 2016
86b44a2
spec update
irees Oct 29, 2016
45c0b95
Serializer update
irees Oct 29, 2016
6f71aac
SSP JSON schema update
irees Oct 29, 2016
d555733
Fix SSP as_change
irees Oct 29, 2016
3d6ca35
SSP Factory update
irees Nov 1, 2016
1cf9481
SSP: frequency dependencies
irees Nov 1, 2016
df1f950
Update json-schema gem
irees Nov 1, 2016
0ce1375
gem tests
irees Nov 2, 2016
3d756b2
Schema fix
irees Nov 2, 2016
fa247e3
Roll back...
irees Nov 2, 2016
34ae87c
Make class method
irees Nov 2, 2016
8fbdd3d
Frequency validation
irees Nov 2, 2016
60df717
TODO...
irees Nov 2, 2016
2c063a3
Revert
irees Nov 2, 2016
7aeeb8d
Spec fix
irees Nov 2, 2016
fc3229c
Frequency dependency specs
irees Nov 2, 2016
8de57c5
require frequency_headway_seconds > 0
irees Nov 2, 2016
3c7bd78
frequency_type: use 'not_exact' instead of 'window'
irees Nov 2, 2016
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
3 changes: 2 additions & 1 deletion app/models/change_payload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ def set_default_values
end

def payload_validation_errors
filename = Rails.root.join('app', 'models', 'json_schemas', 'changeset.json').to_s
JSON::Validator.fully_validate(
File.join(__dir__, 'json_schemas', 'changeset.json'),
filename,
self.payload,
errors_as_objects: true
)
Expand Down
3 changes: 2 additions & 1 deletion app/models/json_schemas/changeset.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
],
"properties": {
"action": {
"type": { "enum": ["createUpdate", "destroy"] }
"type": "string",
"enum": ["createUpdate", "destroy"]
},
"issuesResolved": {
"type": "array",
Expand Down
24 changes: 18 additions & 6 deletions app/models/json_schemas/schedule_stop_pair.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"originOnestopId",
"destinationOnestopId",
"routeOnestopId",
"routeStopPatternOnestopId",
"originArrivalTime",
"originDepartureTime",
"destinationArrivalTime",
Expand All @@ -18,6 +19,13 @@
"windowEnd"
],
"additionalProperties": false,
"dependencies": {
"frequencyType": [
"frequencyStartTime",
"frequencyEndTime",
"frequencyHeadwaySeconds"
]
},
"properties": {
"originOnestopId": {
"type": "string",
Expand All @@ -44,8 +52,8 @@
"windowEnd": { "type": "string" },
"originTimepointSource": { "type": "string" },
"destinationTimepointSource": { "type": "string" },
"originDistTraveled": { "type": "float" },
"destinationDistTraveled": { "type": "float" },
"originDistTraveled": { "type": "number" },
"destinationDistTraveled": { "type": "number" },
"serviceStartDate": {
"type": "string",
"format": "date"
Expand Down Expand Up @@ -82,14 +90,18 @@
"tripHeadsign": { "type": ["string","null"] },
"tripShortName": { "type": ["string","null"] },
"blockId": { "type": ["string","null"] },
"frequencyStartTime": { "type": ["string","null"] },
"frequencyEndTime": { "type": ["string","null"] },
"frequencyHeadwaySeconds": { "type": ["string","null"] },
"frequencyType": {
"type": ["string", "null"],
"enum": ["window", "exact", null]
},
"frequencyStartTime": { "type": ["string"] },
"frequencyEndTime": { "type": ["string"] },
"frequencyHeadwaySeconds": { "type": ["integer"] },
"wheelchairAccessible": { "type": ["boolean","null"] },
"bikesAllowed": { "type": ["boolean","null"] },
"pickupType": { "type": ["string","null"] },
"dropOffType": { "type": ["string","null"] },
"shapeDistTraveled": { "type": ["number","null"] },
"tags": { "type": "object" }
"tags": { "type": ["object","null"] }
}
}
26 changes: 25 additions & 1 deletion app/models/schedule_stop_pair.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# destination_departure_time :string
# frequency_start_time :string
# frequency_end_time :string
# frequency_headway_seconds :string
# tags :hstore
# service_start_date :date
# service_end_date :date
Expand Down Expand Up @@ -44,6 +43,8 @@
# destination_dist_traveled :float
# feed_id :integer
# feed_version_id :integer
# frequency_type :string
# frequency_headway_seconds :integer
#
# Indexes
#
Expand All @@ -56,6 +57,7 @@
# c_ssp_trip (trip)
# index_current_schedule_stop_pairs_on_feed_id_and_id (feed_id,id)
# index_current_schedule_stop_pairs_on_feed_version_id_and_id (feed_version_id,id)
# index_current_schedule_stop_pairs_on_frequency_type (frequency_type)
# index_current_schedule_stop_pairs_on_operator_id (operator_id)
# index_current_schedule_stop_pairs_on_origin_departure_time (origin_departure_time)
# index_current_schedule_stop_pairs_on_route_stop_pattern_id (route_stop_pattern_id)
Expand All @@ -80,6 +82,10 @@ class BaseScheduleStopPair < ActiveRecord::Base
:transitland_interpolated_geometric,
:transitland_interpolated_shape
]
enumerize :frequency_type, in: [
:exact,
:not_exact
]
end

class ScheduleStopPair < BaseScheduleStopPair
Expand Down Expand Up @@ -110,9 +116,15 @@ class ScheduleStopPair < BaseScheduleStopPair
:service_start_date,
:service_end_date,
presence: true
validates :frequency_start_time, presence: true, if: :frequency_type
validates :frequency_end_time, presence: true, if: :frequency_type
validates :frequency_headway_seconds, numericality: { greater_than_or_equal_to: 0, allow_nil: true }
validates :frequency_headway_seconds, presence: true, if: :frequency_type

validate :validate_service_range
validate :validate_service_exceptions


# Add scope for updated_since
include UpdatedSince

Expand Down Expand Up @@ -167,6 +179,10 @@ def route_onestop_id=(value)
self.operator = route.operator
end

def route_stop_pattern_onestop_id
route_stop_pattern.onestop_id
end

def origin_onestop_id
origin.onestop_id
end
Expand Down Expand Up @@ -218,6 +234,14 @@ def destination_departure_time=(value)
super(GTFS::WideTime.parse(value))
end

def frequency_start_time=(value)
super(GTFS::WideTime.parse(value))
end

def frequency_end_time=(value)
super(GTFS::WideTime.parse(value))
end

# Tracked by changeset
include CurrentTrackedByChangeset
current_tracked_by_changeset({
Expand Down
8 changes: 7 additions & 1 deletion app/serializers/schedule_stop_pair_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# destination_departure_time :string
# frequency_start_time :string
# frequency_end_time :string
# frequency_headway_seconds :string
# tags :hstore
# service_start_date :date
# service_end_date :date
Expand Down Expand Up @@ -44,6 +43,8 @@
# destination_dist_traveled :float
# feed_id :integer
# feed_version_id :integer
# frequency_type :string
# frequency_headway_seconds :integer
#
# Indexes
#
Expand All @@ -56,6 +57,7 @@
# c_ssp_trip (trip)
# index_current_schedule_stop_pairs_on_feed_id_and_id (feed_id,id)
# index_current_schedule_stop_pairs_on_feed_version_id_and_id (feed_version_id,id)
# index_current_schedule_stop_pairs_on_frequency_type (frequency_type)
# index_current_schedule_stop_pairs_on_operator_id (operator_id)
# index_current_schedule_stop_pairs_on_origin_departure_time (origin_departure_time)
# index_current_schedule_stop_pairs_on_route_stop_pattern_id (route_stop_pattern_id)
Expand Down Expand Up @@ -96,6 +98,10 @@ class ScheduleStopPairSerializer < ApplicationSerializer
:window_end,
:origin_timepoint_source,
:destination_timepoint_source,
:frequency_start_time,
:frequency_end_time,
:frequency_headway_seconds,
:frequency_type,
:created_at,
:updated_at

Expand Down
Loading