Skip to content

Instantly share code, notes, and snippets.

@gregblake
Created June 11, 2019 14:32
Show Gist options
  • Select an option

  • Save gregblake/d3ce35c323eeb5410f674dac98654283 to your computer and use it in GitHub Desktop.

Select an option

Save gregblake/d3ce35c323eeb5410f674dac98654283 to your computer and use it in GitHub Desktop.
Rails Console Code Used to Test Query Optimizations in PR 11524
[12] pry(main)> room = Connect::Room.find(24259);
Connect::Room Load (1.6ms) SELECT `connect_rooms`.* FROM `connect_rooms` WHERE `connect_rooms`.`id` = 24259 LIMIT 1
[13] pry(main)> room.name
=> "Alex’s Month - Care To Smile - June 02-30 - Alex's Global Chat"
[14] pry(main)> room.users.count;
=> 2636
[15] pry(main)> MobileDevice.count
(1.5ms) SELECT COUNT(*) FROM `mobile_devices`
=> 0
[16] pry(main)> room.users.each do |user|
[16] pry(main)* MobileDevice.create(user: user, device_token: SecureRandom.uuid, platform: "ios", app_id: "an_app_id_that_doesnt_exist")
[16] pry(main)* end
[17] pry(main)> MobileDevice.count
(2.0ms) SELECT COUNT(*) FROM `mobile_devices`
=> 2636
# An `at-all` mention in Alex's Month room triggers desktop and push notifications to 2,636 users (one mobile_device per user):
[2] pry(main)> Connect::Message.create(from: User.find(618), to: room, body: "u#all")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment