Last active
November 19, 2018 11:41
-
-
Save edipofederle/33188243fc0da9aaa15f6d03341e4547 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for future bookings | |
ActiveRecord::Base.logger.level = 1 # disable query logs | |
bookings = Booking.where('check_out >= ?', Time.now);nil | |
bookings.each do |booking| | |
city = booking&.property&.city | |
new_value = booking.decorate.check_out.change(hour: 11, min: 0) | |
booking.guest_check_out_at = city ? city.utc_time(new_value) : new_value | |
PaperTrail.whodunnit('Edipo F: set initial value for guest_check_out_at') do | |
booking.save(validate: false) | |
end | |
end;nil | |
# for past bookings (make sense ?) - leave it as is | |
ActiveRecord::Base.logger.level = 1 # disable query logs | |
bookings = Booking.where('check_out < ?', Time.now).where(guest_check_out_at: nil);nil | |
bookings.each do |booking| | |
booking.guest_check_out_at = booking.check_out.change(hour: 11) | |
booking.save(validate: false);nil | |
end |
city = booking&.property&.city
new_value = booking.decorate.check_out.change(hour: 11, min: 0)
booking.guest_check_out_at = city ? city.utc_time(new_value) : new_value
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ok