Skip to content

Commit

Permalink
Handle stray dates
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenyeargin committed Mar 16, 2024
1 parent 348bec6 commit 24ede57
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/tasks/import.rake
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ namespace :import do
puts 'calendar_dates.txt'
begin
@source = GTFS::Source.build ENV.fetch('GTFS_URL', nil)
CalendarDate.bulk_insert do |worker|
@source.each_calendar_date do |row|
worker.add(CalendarDate.hash_from_gtfs(row))
@source.each_calendar_date do |row|
date = CalendarDate.new(CalendarDate.hash_from_gtfs(row))
if date.calendar_id.nil?
puts "[ERROR] Calendar ID is nil for #{date.service_id} / #{date.date}"
next
end

date.save
end
rescue Errno::ENOENT
puts '[warning] File does not exist.'
Expand Down

0 comments on commit 24ede57

Please sign in to comment.