Created
February 16, 2012 23:08
-
-
Save simonista/1848627 to your computer and use it in GitHub Desktop.
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
if connection.adapter_name =~ /mysql/i | |
connection.execute <<-SQL | |
UPDATE users, conversation_participants cp | |
SET unread_conversations_count = unread_conversations_count + 1 | |
WHERE users.id = cp.user_id AND #{cp_conditions} | |
SQL | |
else | |
User.update_all 'unread_conversations_count = unread_conversations_count + 1', | |
"id IN (SELECT user_id FROM conversation_participants cp WHERE #{cp_conditions})" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment