Skip to content

Commit

Permalink
Merge pull request #1002 from sparc-request/jm-no-such-file-productio…
Browse files Browse the repository at this point in the history
…n-bug

JM - (Production Bug) An Errno::ENOENT occurred in service_requests#c…
  • Loading branch information
Stuart-Johnson committed Jul 14, 2017
2 parents c5cc312 + ec8a2d9 commit ca9361a
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions app/controllers/service_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -388,24 +388,27 @@ def setup_catalog_calendar

@events = []
begin
#to parse file and get events
cal_file = File.open(Rails.root.join("tmp", "basic.ics"))
path = Rails.root.join("tmp", "basic.ics")
if path.exist?
#to parse file and get events
cal_file = File.open(path)

cals = Icalendar.parse(cal_file)
cals = Icalendar.parse(cal_file)

cal = cals.first
cal = cals.first

events = cal.try(:events).try(:sort) { |x, y| y.dtstart <=> x.dtstart } || []
events = cal.try(:events).try(:sort) { |x, y| y.dtstart <=> x.dtstart } || []

events.each do |event|
next if Time.parse(event.dtstart.to_s) > startMax
break if Time.parse(event.dtstart.to_s) < startMin
@events << create_calendar_event(event)
end
events.each do |event|
next if Time.parse(event.dtstart.to_s) > startMax
break if Time.parse(event.dtstart.to_s) < startMin
@events << create_calendar_event(event)
end

@events.reverse!
@events.reverse!

Alert.where(alert_type: ALERT_TYPES['google_calendar'], status: ALERT_STATUSES['active']).update_all(status: ALERT_STATUSES['clear'])
Alert.where(alert_type: ALERT_TYPES['google_calendar'], status: ALERT_STATUSES['active']).update_all(status: ALERT_STATUSES['clear'])
end
rescue Exception => e
active_alert = Alert.where(alert_type: ALERT_TYPES['google_calendar'], status: ALERT_STATUSES['active']).first_or_initialize
if Rails.env == 'production' && active_alert.new_record?
Expand Down

0 comments on commit ca9361a

Please sign in to comment.