Skip to content

Instantly share code, notes, and snippets.

@mrship
Created July 13, 2019 13:06
Show Gist options
  • Save mrship/8f56275d83e1684d8bfac60f5bbfa578 to your computer and use it in GitHub Desktop.
Save mrship/8f56275d83e1684d8bfac60f5bbfa578 to your computer and use it in GitHub Desktop.
select airbnb_bookings.id, airbnb_links.airbnb_connection_id from airbnb_bookings join bookings ON bookings.id = airbnb_bookings.booking_
 id join properties ON properties.id = bookings.property_id join airbnb_links ON airbnb_links.property_id = properties.id where bookings.id in (__booking_ids__)
airbnb_booking_id = __airbnb_booking_id__;
airbnb_connection_id = __airbnb_connection_id__;

thread = AirbnbBookingRepository.new.find(airbnb_booking_id).thread;

airbnb_thread = nil;

AirbnbThread::Upsert.new(thread: thread, airbnb_connection_id: airbnb_connection_id).tap do |so| 
  so.on(:airbnb_thread_upserted) { |upserted_thread| airbnb_thread = upserted_thread };
  so.call;
end;
__airbnb_thread_id__ = airbnb_thread.id
update airbnb_bookings set airbnb_thread_id=__airbnb_thread_id__ where id=__airbnb_booking_id__;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment