Skip to content

Commit

Permalink
feat(locker_booking_sync_spec): initial work on spec
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Feb 9, 2025
1 parent d67d54b commit 1106c1e
Show file tree
Hide file tree
Showing 4 changed files with 487 additions and 15 deletions.
2 changes: 1 addition & 1 deletion drivers/place/auto_release_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class StaffAPI < DriverSpecs::MockDriver
self[:rejected] = 0
end

def reject(booking_id : String | Int64, utm_source : String? = nil)
def reject(booking_id : String | Int64, utm_source : String? = nil, instance : Int64? = nil)
self[:rejected] = self[:rejected].as_i + 1
end

Expand Down
4 changes: 2 additions & 2 deletions drivers/place/booking_model.cr
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class Place::Booking
property booked_by_name : String
property booked_by_email : String

getter checked_out_at : Int64? = nil
getter deleted : Bool? = nil
property checked_out_at : Int64? = nil
property deleted : Bool? = nil
property checked_in : Bool { false }
property title : String?
property description : String?
Expand Down
5 changes: 4 additions & 1 deletion drivers/place/bookings/locker_booking_sync.cr
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ class Place::Bookings::LockerBookingSync < PlaceOS::Driver
place_bookings.find { |book| book.asset_id == booking.asset_id && (book.user_id == booking.user_id || book.user_email.downcase == booking.user_email.downcase) }
end

logger.debug { "planning to allocate #{allocate_lockers.size}, release #{release_lockers.size} and check #{place_bookings.size} against #{lockers.size} allocations -- id:#{unique_id}" }

# remove allocations where a place booking has been checked out
# ensure the locker is still allocated to that user
allocated = 0
Expand Down Expand Up @@ -220,7 +222,8 @@ class Place::Bookings::LockerBookingSync < PlaceOS::Driver
# resolve this below if this step failed in a previous run
if locker
logger.debug { " -- update #{locker.locker_id} booking state on #{place_booking.id} to #{locker.allocation_id} -- id:#{unique_id}" }
staff_api.booking_state(place_booking.id, locker.allocation_id)
staff_api.booking_state(place_booking.id, locker.allocation_id) if place_booking.instance
staff_api.booking_state(place_booking.id, locker.allocation_id, instance: place_booking.instance)
allocated += 1
else
alloc_failed << place_booking
Expand Down
Loading

0 comments on commit 1106c1e

Please sign in to comment.