Created
April 7, 2012 14:29
-
-
Save mrnugget/2329363 to your computer and use it in GitHub Desktop.
Wat?
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
# While looking at a page, I create a comment in the background: | |
irb(main):005:0> Time.now | |
=> 2012-04-07 16:27:49 +0200 | |
irb(main):006:0> new_comment = Comment.create!(user: User.first, song: Song.last, text: "Hello3") | |
User Load (0.3ms) SELECT "users".* FROM "users" LIMIT 1 | |
Song Load (0.2ms) SELECT "songs".* FROM "songs" ORDER BY "songs"."id" DESC LIMIT 1 | |
(0.1ms) begin transaction | |
SQL (0.5ms) INSERT INTO "comments" ("created_at", "song_id", "text", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?) [["created_at", Sat, 07 Apr 2012 14:27:51 UTC +00:00], ["song_id", 95], ["text", "Hello3"], ["updated_at", Sat, 07 Apr 2012 14:27:51 UTC +00:00], ["user_id", 1]] | |
(2.7ms) commit transaction | |
=> #<Comment id: 32, user_id: 1, text: "Hello3", created_at: "2012-04-07 14:27:51", updated_at: "2012-04-07 14:27:51", song_id: 95> | |
# Now I reload the page, and I should get an indicator telling me that there is a new comment... From the server output, the query that looks for the new comments since my last activity (saved in a cookie as timestamp): | |
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]] | |
(0.1ms) SELECT COUNT(*) FROM "comments" WHERE (created_at > '2012-04-07 16:27:32 +0200') | |
CACHE (0.0ms) SELECT COUNT(*) FROM "comments" WHERE (created_at > '2012-04-07 16:27:32 +0200') | |
# | |
# | |
# | |
# All this was done in a timeframe of 20 seconds. The last cookie was set at 16:27:32 +0200, the comments where created at 14:27:51 - which should be 16:27:51 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment