We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ad24db7 commit 03c4dcbCopy full SHA for 03c4dcb
app/models/application.rb
@@ -23,10 +23,12 @@ def self.aggregate_chats_count
23
# Their might be an ActiveRecord-based approach but I couldn't find any.
24
self.connection.execute(
25
'UPDATE applications apps
26
- JOIN(SELECT application_id, COUNT(application_id) as aggregation
27
- FROM chats
28
- GROUP BY application_id) c ON apps.id = c.application_id
29
- SET apps.chats_count = c.aggregation;'
+ JOIN(
+ SELECT application_id, COUNT(application_id) as aggregation
+ FROM chats
+ GROUP BY application_id
30
+ ) chats ON apps.id = chats.application_id
31
+ SET apps.chats_count = chats.aggregation;'
32
)
33
end
34
0 commit comments