gtfs_engine 1.5.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +6 -5
  3. data/app/controllers/gtfs_engine/agencies_controller.rb +2 -14
  4. data/app/controllers/gtfs_engine/application_controller.rb +2 -14
  5. data/app/controllers/gtfs_engine/calendar_dates_controller.rb +2 -14
  6. data/app/controllers/gtfs_engine/calendars_controller.rb +7 -19
  7. data/app/controllers/gtfs_engine/data_sets_controller.rb +10 -24
  8. data/app/controllers/gtfs_engine/fare_attributes_controller.rb +2 -14
  9. data/app/controllers/gtfs_engine/fare_rules_controller.rb +2 -14
  10. data/app/controllers/gtfs_engine/feed_infos_controller.rb +2 -14
  11. data/app/controllers/gtfs_engine/frequencies_controller.rb +2 -14
  12. data/app/controllers/gtfs_engine/routes_controller.rb +2 -14
  13. data/app/controllers/gtfs_engine/shapes_controller.rb +2 -14
  14. data/app/controllers/gtfs_engine/stop_times_controller.rb +2 -14
  15. data/app/controllers/gtfs_engine/stops_controller.rb +2 -14
  16. data/app/controllers/gtfs_engine/transfers_controller.rb +9 -21
  17. data/app/controllers/gtfs_engine/trips_controller.rb +4 -16
  18. data/app/helpers/gtfs_engine/default_views_helper.rb +8 -21
  19. data/app/helpers/gtfs_engine/fields_helper.rb +3 -15
  20. data/app/models/gtfs_engine/agency.rb +3 -15
  21. data/app/models/gtfs_engine/calendar.rb +21 -38
  22. data/app/models/gtfs_engine/calendar_date.rb +5 -17
  23. data/app/models/gtfs_engine/data_set.rb +20 -32
  24. data/app/models/gtfs_engine/fare_attribute.rb +3 -15
  25. data/app/models/gtfs_engine/fare_rule.rb +9 -23
  26. data/app/models/gtfs_engine/feed_info.rb +3 -15
  27. data/app/models/gtfs_engine/frequency.rb +5 -17
  28. data/app/models/gtfs_engine/route.rb +4 -17
  29. data/app/models/gtfs_engine/shape.rb +5 -17
  30. data/app/models/gtfs_engine/stop.rb +5 -18
  31. data/app/models/gtfs_engine/stop_time.rb +5 -19
  32. data/app/models/gtfs_engine/transfer.rb +5 -17
  33. data/app/models/gtfs_engine/trip.rb +8 -25
  34. data/app/views/gtfs_engine/calendars/dates.json.jsend +3 -17
  35. data/app/views/gtfs_engine/data_sets/index.json.jsend +4 -18
  36. data/app/views/gtfs_engine/data_sets/show.json.jsend +2 -16
  37. data/app/views/gtfs_engine/gtfs/index.json.jsend +1 -15
  38. data/app/views/gtfs_engine/gtfs/show.json.jsend +1 -15
  39. data/app/views/gtfs_engine/transfers/from.json.jsend +1 -15
  40. data/app/views/gtfs_engine/transfers/from_to.json.jsend +1 -15
  41. data/app/views/gtfs_engine/transfers/to.json.jsend +1 -15
  42. data/app/views/gtfs_engine/trips/block.json.jsend +1 -15
  43. data/bin/rails +5 -3
  44. data/config/routes.rb +3 -16
  45. data/db/migrate/20140320045108_create_gtfs_engine_data_sets.rb +2 -0
  46. data/db/migrate/20140320045232_create_gtfs_engine_calendars.rb +2 -0
  47. data/db/migrate/20140320045751_create_gtfs_engine_calendar_dates.rb +2 -0
  48. data/db/migrate/20140320050100_create_gtfs_engine_shapes.rb +2 -0
  49. data/db/migrate/20140320051140_create_gtfs_engine_routes.rb +4 -2
  50. data/db/migrate/20140320052005_create_gtfs_engine_stops.rb +4 -2
  51. data/db/migrate/20140320052508_create_gtfs_engine_trips.rb +3 -1
  52. data/db/migrate/20140320052907_create_gtfs_engine_stop_times.rb +2 -0
  53. data/db/migrate/20140401032609_create_gtfs_engine_agencies.rb +2 -0
  54. data/db/migrate/20140405235947_create_gtfs_engine_fare_attributes.rb +2 -0
  55. data/db/migrate/20140406063500_create_gtfs_engine_fare_rules.rb +3 -1
  56. data/db/migrate/20140406071922_create_gtfs_engine_frequencies.rb +2 -0
  57. data/db/migrate/20140406072309_create_gtfs_engine_transfers.rb +2 -0
  58. data/db/migrate/20140406073548_create_gtfs_engine_feed_infos.rb +2 -0
  59. data/lib/gtfs_engine.rb +2 -14
  60. data/lib/gtfs_engine/concerns.rb +2 -14
  61. data/lib/gtfs_engine/concerns/controllers.rb +10 -18
  62. data/lib/gtfs_engine/concerns/controllers/data_access.rb +28 -40
  63. data/lib/gtfs_engine/concerns/controllers/gtfs.rb +17 -50
  64. data/lib/gtfs_engine/engine.rb +2 -15
  65. data/lib/gtfs_engine/exceptions.rb +4 -19
  66. data/lib/gtfs_engine/json_responder.rb +9 -23
  67. data/lib/gtfs_engine/middleware/base.rb +6 -19
  68. data/lib/gtfs_engine/middleware/json_parse_errors.rb +6 -20
  69. data/lib/gtfs_engine/sources.rb +33 -44
  70. data/lib/gtfs_engine/version.rb +30 -37
  71. data/lib/tasks/gtfs_engine_tasks.rake +15 -25
  72. metadata +36 -43
@@ -1,31 +1,18 @@
1
- # This file is part of the KNOWtime server.
2
- #
3
- # The KNOWtime server is free software: you can redistribute it and/or modify it
4
- # under the terms of the GNU General Public License as published by the Free
5
- # Software Foundation, either version 3 of the License, or (at your option) any
6
- # later version.
7
- #
8
- # The KNOWtime server is distributed in the hope that it will be useful, but
9
- # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
- # details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
15
3
  module GtfsEngine
16
4
  module DefaultViewsHelper
17
5
  def index(json, records)
18
- json.cache! [controller_name, filter] do
19
- json.ignore_nil! true
20
- json.array!(records) {|record| json.extract! record, *fields }
6
+ json.cache!([controller_name, filter]) do
7
+ json.ignore_nil!(true)
8
+ json.array!(records) { |record| json.extract!(record, *fields) }
21
9
  end
22
10
  end
23
11
 
24
-
25
12
  def show(json, record)
26
- json.cache! record do
27
- json.ignore_nil! true
28
- json.extract! record, *fields
13
+ json.cache!(record) do
14
+ json.ignore_nil!(true)
15
+ json.extract!(record, *fields)
29
16
  end
30
17
  end
31
18
  end
@@ -1,17 +1,5 @@
1
- # This file is part of the KNOWtime server.
2
- #
3
- # The KNOWtime server is free software: you can redistribute it and/or modify it
4
- # under the terms of the GNU General Public License as published by the Free
5
- # Software Foundation, either version 3 of the License, or (at your option) any
6
- # later version.
7
- #
8
- # The KNOWtime server is distributed in the hope that it will be useful, but
9
- # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
- # details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
15
3
  module GtfsEngine
16
4
  module FieldsHelper
17
5
  def fields
@@ -26,7 +14,7 @@ module GtfsEngine
26
14
 
27
15
  def create_fields
28
16
  attributes = GtfsEngine.const_get(model).attribute_names
29
- attributes - %w(id data_set_id)
17
+ attributes - %w[id data_set_id]
30
18
  end
31
19
  end
32
20
  end
@@ -1,19 +1,7 @@
1
- # This file is part of the KNOWtime server.
2
- #
3
- # The KNOWtime server is free software: you can redistribute it and/or modify it
4
- # under the terms of the GNU General Public License as published by the Free
5
- # Software Foundation, either version 3 of the License, or (at your option) any
6
- # later version.
7
- #
8
- # The KNOWtime server is distributed in the hope that it will be useful, but
9
- # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
- # details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
15
3
  module GtfsEngine
16
4
  class Agency < ActiveRecord::Base
17
- belongs_to :data_set, inverse_of: :agencies
5
+ belongs_to :data_set, optional: false
18
6
  end
19
7
  end
@@ -1,32 +1,17 @@
1
- # This file is part of the KNOWtime server.
2
- #
3
- # The KNOWtime server is free software: you can redistribute it and/or modify it
4
- # under the terms of the GNU General Public License as published by the Free
5
- # Software Foundation, either version 3 of the License, or (at your option) any
6
- # later version.
7
- #
8
- # The KNOWtime server is distributed in the hope that it will be useful, but
9
- # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
- # details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
15
3
  module GtfsEngine
16
4
  class Calendar < ActiveRecord::Base
17
- belongs_to :data_set, inverse_of: :calendars
5
+ belongs_to :data_set, optional: false
18
6
 
19
- has_many :calendar_dates, inverse_of: :calendar,
20
- foreign_key: :service_id, primary_key: :service_id
21
- has_many :trips, inverse_of: :calendar,
22
- foreign_key: :service_id, primary_key: :service_id
7
+ has_many :calendar_dates, foreign_key: :service_id, primary_key: :service_id
8
+ has_many :trips, foreign_key: :service_id, primary_key: :service_id
23
9
 
24
10
  has_many :routes, through: :trips
25
11
  has_many :shapes, through: :trips
26
12
 
27
13
  alias_attribute :dates, :calendar_dates
28
14
 
29
-
30
15
  class << self
31
16
  # @return <ActiveRecord_Relation> the set of Calendars that include the
32
17
  # given date.
@@ -35,22 +20,22 @@ module GtfsEngine
35
20
  #
36
21
  # TODO: Currently, this method does 3 SQL queries. Try to lower this.
37
22
  def from_date_string(date)
38
- dates = GtfsEngine::CalendarDate.where date: date
23
+ dates = GtfsEngine::CalendarDate.where(date: date)
39
24
 
40
- add = dates.where(exception_type: 1).pluck :service_id
25
+ add = dates.where(exception_type: 1).pluck(:service_id)
41
26
  query =
42
27
  if add.any?
43
- where '((start_date <= :date AND end_date >= :date)
44
- OR service_id IN (:ids)', date: date, ids: add
28
+ where('((start_date <= :date AND end_date >= :date)
29
+ OR service_id IN (:ids)', date: date, ids: add)
45
30
  else
46
- where '(start_date <= :date AND end_date >= :date)', date: date
31
+ where('(start_date <= :date AND end_date >= :date)', date: date)
47
32
  end
48
33
 
49
- query = where_day_of_week query, date
34
+ query = where_day_of_week(query, date)
50
35
 
51
- rem = dates.where(exception_type: 2).pluck :service_id
36
+ rem = dates.where(exception_type: 2).pluck(:service_id)
52
37
  if rem.any?
53
- query.where '(service_id NOT IN (?))', rem
38
+ query.where('(service_id NOT IN (?))', rem)
54
39
  else
55
40
  query
56
41
  end
@@ -61,19 +46,17 @@ module GtfsEngine
61
46
  # Modifies the given query to only matches the day of the week represented
62
47
  # by the given date (format: YYYY-MM-DD)
63
48
  def where_day_of_week(query, date_str)
64
- case Date.new( *date_str.split('-').map(&:to_i) ).cwday
65
- when 1 then query.where monday: true
66
- when 2 then query.where tuesday: true
67
- when 3 then query.where wednesday: true
68
- when 4 then query.where thursday: true
69
- when 5 then query.where friday: true
70
- when 6 then query.where saturday: true
71
- else query.where sunday: true
49
+ case Date.new(*date_str.split('-').map(&:to_i)).cwday
50
+ when 1 then query.where(monday: true)
51
+ when 2 then query.where(tuesday: true)
52
+ when 3 then query.where(wednesday: true)
53
+ when 4 then query.where(thursday: true)
54
+ when 5 then query.where(friday: true)
55
+ when 6 then query.where(saturday: true)
56
+ else query.where(sunday: true)
72
57
  end
73
58
  end
74
-
75
59
  end
76
-
77
60
  end
78
61
 
79
62
  DateFormatError = Class.new StandardError
@@ -1,21 +1,9 @@
1
- # This file is part of the KNOWtime server.
2
- #
3
- # The KNOWtime server is free software: you can redistribute it and/or modify it
4
- # under the terms of the GNU General Public License as published by the Free
5
- # Software Foundation, either version 3 of the License, or (at your option) any
6
- # later version.
7
- #
8
- # The KNOWtime server is distributed in the hope that it will be useful, but
9
- # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
- # details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
15
3
  module GtfsEngine
16
4
  class CalendarDate < ActiveRecord::Base
17
- belongs_to :data_set, inverse_of: :calendar_dates
18
- belongs_to :calendar, inverse_of: :calendar_dates,
19
- foreign_key: :service_id, primary_key: :service_id
5
+ belongs_to :data_set, optional: false
6
+ belongs_to :calendar, optional: false,
7
+ foreign_key: :service_id, primary_key: :service_id
20
8
  end
21
9
  end
@@ -1,38 +1,26 @@
1
- # This file is part of the KNOWtime server.
2
- #
3
- # The KNOWtime server is free software: you can redistribute it and/or modify it
4
- # under the terms of the GNU General Public License as published by the Free
5
- # Software Foundation, either version 3 of the License, or (at your option) any
6
- # later version.
7
- #
8
- # The KNOWtime server is distributed in the hope that it will be useful, but
9
- # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
- # details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
15
3
  module GtfsEngine
16
4
  class DataSet < ActiveRecord::Base
17
- with_options inverse_of: :data_set, dependent: :delete_all do |set|
18
- set.has_many :agencies
19
- set.has_many :calendars
20
- set.has_many :calendar_dates
21
- set.has_many :fare_attributes
22
- set.has_many :fare_rules
23
- set.has_many :feed_infos
24
- set.has_many :frequencies
25
- set.has_many :routes
26
- set.has_many :shapes
27
- set.has_many :stops
28
- set.has_many :stop_times
29
- set.has_many :transfers
30
- set.has_many :trips
5
+ with_options dependent: :delete_all do |set|
6
+ set.has_many(:agencies)
7
+ set.has_many(:calendars)
8
+ set.has_many(:calendar_dates)
9
+ set.has_many(:fare_attributes)
10
+ set.has_many(:fare_rules)
11
+ set.has_many(:feed_infos)
12
+ set.has_many(:frequencies)
13
+ set.has_many(:routes)
14
+ set.has_many(:shapes)
15
+ set.has_many(:stops)
16
+ set.has_many(:stop_times)
17
+ set.has_many(:transfers)
18
+ set.has_many(:trips)
31
19
  end
32
20
 
33
21
  scope :newest, -> { order(created_at: :desc).first }
34
22
 
35
- #@return [Hash] a hash of each record type and the number of records in
23
+ # @return [Hash] a hash of each record type and the number of records in
36
24
  # this data set
37
25
  def details
38
26
  Rails.cache.fetch("gtfs_data_set_details_#{id}") { create_details }
@@ -47,13 +35,13 @@ module GtfsEngine
47
35
  private
48
36
 
49
37
  def create_details
50
- self.class.reflections.select do |name, assoc|
38
+ self.class.reflections.select do |_name, assoc|
51
39
  assoc.macro == :has_many && assoc.options[:inverse_of] == :data_set
52
40
  end.each_with_object({}) do |(name, _), hash|
53
41
  controller_class = association_controller_class name
54
42
  hash[name] = {
55
- count: send(name).count,
56
- filters: controller_class.filters
43
+ count: send(name).count,
44
+ filters: controller_class.filters
57
45
  }
58
46
  end
59
47
  end
@@ -1,19 +1,7 @@
1
- # This file is part of the KNOWtime server.
2
- #
3
- # The KNOWtime server is free software: you can redistribute it and/or modify it
4
- # under the terms of the GNU General Public License as published by the Free
5
- # Software Foundation, either version 3 of the License, or (at your option) any
6
- # later version.
7
- #
8
- # The KNOWtime server is distributed in the hope that it will be useful, but
9
- # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
- # details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
15
3
  module GtfsEngine
16
4
  class FareAttribute < ActiveRecord::Base
17
- belongs_to :data_set, inverse_of: :fare_attributes
5
+ belongs_to :data_set, optional: false
18
6
  end
19
7
  end
@@ -1,30 +1,16 @@
1
- # This file is part of the KNOWtime server.
2
- #
3
- # The KNOWtime server is free software: you can redistribute it and/or modify it
4
- # under the terms of the GNU General Public License as published by the Free
5
- # Software Foundation, either version 3 of the License, or (at your option) any
6
- # later version.
7
- #
8
- # The KNOWtime server is distributed in the hope that it will be useful, but
9
- # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
- # details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
15
3
  module GtfsEngine
16
4
  class FareRule < ActiveRecord::Base
17
5
  belongs_to :data_set, inverse_of: :trips
18
- belongs_to :fare_attribute, inverse_of: :fare_rules,
19
- foreign_key: :fare_id, primary_key: :fare_id
20
- belongs_to :route, inverse_of: :fare_rules,
21
- foreign_key: :route_id, primary_key: :route_id
6
+ belongs_to :fare_attribute, foreign_key: :fare_id, primary_key: :fare_id
7
+ belongs_to :route, foreign_key: :route_id, primary_key: :route_id
22
8
 
23
- with_options class_name: 'Stop', primary_key: :zone_id do |rule|
24
- rule.belongs_to :origin, inverse_of: :origin_rules,
25
- foreign_key: :origin_id
26
- rule.belongs_to :destination, inverse_of: :destination_rules,
27
- foreign_key: :destination_id
9
+ with_options(class_name: 'Stop', primary_key: :zone_id) do |rule|
10
+ rule.belongs_to(:origin, inverse_of: :origin_rules,
11
+ foreign_key: :origin_id)
12
+ rule.belongs_to(:destination, inverse_of: :destination_rules,
13
+ foreign_key: :destination_id)
28
14
  end
29
15
  end
30
16
  end
@@ -1,19 +1,7 @@
1
- # This file is part of the KNOWtime server.
2
- #
3
- # The KNOWtime server is free software: you can redistribute it and/or modify it
4
- # under the terms of the GNU General Public License as published by the Free
5
- # Software Foundation, either version 3 of the License, or (at your option) any
6
- # later version.
7
- #
8
- # The KNOWtime server is distributed in the hope that it will be useful, but
9
- # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
- # details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
15
3
  module GtfsEngine
16
4
  class FeedInfo < ActiveRecord::Base
17
- belongs_to :data_set, inverse_of: :feed_infos
5
+ belongs_to :data_set, optional: false
18
6
  end
19
7
  end
@@ -1,21 +1,9 @@
1
- # This file is part of the KNOWtime server.
2
- #
3
- # The KNOWtime server is free software: you can redistribute it and/or modify it
4
- # under the terms of the GNU General Public License as published by the Free
5
- # Software Foundation, either version 3 of the License, or (at your option) any
6
- # later version.
7
- #
8
- # The KNOWtime server is distributed in the hope that it will be useful, but
9
- # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
- # details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
15
3
  module GtfsEngine
16
4
  class Frequency < ActiveRecord::Base
17
- belongs_to :data_set, inverse_of: :frequencies
18
- belongs_to :trip, inverse_of: :frequencies,
19
- foreign_key: :trip_id, primary_key: :trip_id
5
+ belongs_to :data_set, optional: false
6
+ belongs_to :trip, optional: false,
7
+ foreign_key: :trip_id, primary_key: :trip_id
20
8
  end
21
9
  end
@@ -1,23 +1,10 @@
1
- # This file is part of the KNOWtime server.
2
- #
3
- # The KNOWtime server is free software: you can redistribute it and/or modify it
4
- # under the terms of the GNU General Public License as published by the Free
5
- # Software Foundation, either version 3 of the License, or (at your option) any
6
- # later version.
7
- #
8
- # The KNOWtime server is distributed in the hope that it will be useful, but
9
- # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
- # details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
15
3
  module GtfsEngine
16
4
  class Route < ActiveRecord::Base
17
- belongs_to :data_set, inverse_of: :routes
5
+ belongs_to :data_set, optional: false
18
6
 
19
- has_many :trips, inverse_of: :route,
20
- foreign_key: :route_id, primary_key: :route_id
7
+ has_many :trips, foreign_key: :route_id, primary_key: :route_id
21
8
 
22
9
  has_many :calendars, through: :trips
23
10
  has_many :shapes, through: :trips
@@ -1,21 +1,9 @@
1
- # This file is part of the KNOWtime server.
2
- #
3
- # The KNOWtime server is free software: you can redistribute it and/or modify it
4
- # under the terms of the GNU General Public License as published by the Free
5
- # Software Foundation, either version 3 of the License, or (at your option) any
6
- # later version.
7
- #
8
- # The KNOWtime server is distributed in the hope that it will be useful, but
9
- # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
- # details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
15
3
  module GtfsEngine
16
4
  class Shape < ActiveRecord::Base
17
- belongs_to :data_set, inverse_of: :shapes
18
- belongs_to :trip, inverse_of: :shapes,
19
- foreign_key: :shape_id, primary_key: :shape_id
5
+ belongs_to :data_set, optional: false
6
+ belongs_to :trip, optional: false,
7
+ foreign_key: :shape_id, primary_key: :shape_id
20
8
  end
21
9
  end