aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/models/concerns/application_days_support.rb8
-rw-r--r--app/models/import/gtfs.rb20
2 files changed, 27 insertions, 1 deletions
diff --git a/app/models/concerns/application_days_support.rb b/app/models/concerns/application_days_support.rb
index 2d00b5847..6086d9580 100644
--- a/app/models/concerns/application_days_support.rb
+++ b/app/models/concerns/application_days_support.rb
@@ -10,8 +10,10 @@ module ApplicationDaysSupport
SUNDAY = 256
EVERYDAY = MONDAY | TUESDAY | WEDNESDAY | THURSDAY | FRIDAY | SATURDAY | SUNDAY
+ ALL_DAYS = %w(monday tuesday wednesday thursday friday saturday sunday).freeze
+
def display_day_types
- %w(monday tuesday wednesday thursday friday saturday sunday).select{ |d| self.send(d) }.map{ |d| self.human_attribute_name(d).first(2)}.join(', ')
+ ALL_DAYS.select{ |d| self.send(d) }.map{ |d| self.human_attribute_name(d).first(2)}.join(', ')
end
def day_by_mask(flag)
@@ -39,6 +41,10 @@ module ApplicationDaysSupport
def self.day_by_mask(int_day_types,flag)
int_day_types & flag == flag
end
+
+ def self.all_days
+ ALL_DAYS
+ end
end
def valid_days
diff --git a/app/models/import/gtfs.rb b/app/models/import/gtfs.rb
index 5b332315d..75ff45f8b 100644
--- a/app/models/import/gtfs.rb
+++ b/app/models/import/gtfs.rb
@@ -111,6 +111,8 @@ class Import::Gtfs < Import::Base
vehicle_journey.published_journey_name = trip.headsign.presence || trip.id
save vehicle_journey
+ vehicle_journey.time_tables << referential.time_tables.find(time_tables_by_service_id[trip.service_id])
+
vehicle_journey_by_trip_id[trip.id] = vehicle_journey.id
end
end
@@ -143,6 +145,24 @@ class Import::Gtfs < Import::Base
end
end
+ def time_tables_by_service_id
+ @time_tables_by_service_id ||= {}
+ end
+
+ def import_calendars
+ source.calendars.each do |calendar|
+ time_table = referential.time_tables.build comment: "Calendar #{calendar.service_id}"
+ Chouette::TimeTable.all_days.each do |day|
+ time_table.send("#{day}=", calendar.send(day))
+ end
+ time_table.periods.build period_start: calendar.start_date, period_end: calendar.end_date
+
+ save time_table
+
+ time_tables_by_service_id[calendar.service_id] = time_table.id
+ end
+ end
+
def save(model)
unless model.save
Rails.logger.info "Can't save #{model.class.name} : #{model.errors.inspect}"