Skip to content

Instantly share code, notes, and snippets.

@electronicbites
Last active January 29, 2018 16:55
Show Gist options
  • Save electronicbites/757791c99f6e17214e9e8934cc3b204a to your computer and use it in GitHub Desktop.
Save electronicbites/757791c99f6e17214e9e8934cc3b204a to your computer and use it in GitHub Desktop.
r = Restaurant.find ‘coda'
#di-do
st_bar = ShiftTemplate.find(261)
st_dinner = ShiftTemplate.find(236)
st_dinner.end_time = st_bar.end_time
st_dinner.save
st_dinner.reset_shifts
## ??? reset did not work as expected (end_time anpassen)
st_dinner.shifts.future.each do |shift|
shift.end_time = shift.shift_template.end_time_for_shift_for_date shift.start_time
shift.save!
ShiftCache.new(shift).reset_cache
end
st_dinner.shifts.future.each{|s| ShiftCache.new(s).reset_cache}
shift_time_rule = Shift.find(203912).shift_time_rule
shift_time_rule.valid_until = 1.day.ago
shift_time_rule.save
st_bar.bookings.future
st_bar.shifts.collect{|s| s.bookings.future}.flatten.each do |booking|
new_shift = st_dinner.shifts.same_date(booking.shift.start_time.to_date).first
booking.shift = new_shift
booking.save!
end
st_bar.shifts.future.destroy_all
#weekend
st_bar = ShiftTemplate.find(260)
st_dinner = ShiftTemplate.find(230)
st_dinner.end_time = st_bar.end_time
st_dinner.save
st_dinner.reset_shifts
st_dinner.shifts.future.each do |shift|
shift.end_time = shift.shift_template.end_time_for_shift_for_date shift.start_time
shift.save!
ShiftCache.new(shift).reset_cache
end
shift_time_rule = st_bar.shifts.future.first.shift_time_rule
shift_time_rule.valid_until = 1.day.ago
shift_time_rule.save
st_bar.shifts.collect{|s| s.bookings.future}.flatten.each do |booking|
new_shift = st_dinner.shifts.same_date(booking.shift.start_time.to_date).first
booking.shift = new_shift
booking.save!
end
st_bar.shifts.future.destroy_all
st_bar.time_slot_templates.each{|ts| st_dinner.time_slot_templates << ts}
shift = r.shifts.per_name('dinner').overlaps(Date.parse('14.02.2018').beginning_of_day, Date.parse('14.02.2018').end_of_day).last
st_old = shift
shift.shift_template = st_new
shift.shift_time_rule_id = st_new.shift_time_rules
BookingServiceCache.new.reset_complete_cache r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment