Commit f0426bdc0a3f9c8d1332df2557ade591c99fe37d
1 parent
f3991755
Exists in
master
and in
29 other branches
Got recent_conversations algorithm
Showing
1 changed file
with
5 additions
and
0 deletions
Show diff stats
app/controllers/public/chat_controller.rb
... | ... | @@ -63,6 +63,11 @@ class ChatController < PublicController |
63 | 63 | render :json => messages_json.reverse |
64 | 64 | end |
65 | 65 | |
66 | + def recent_conversations | |
67 | + conversations_order = ActiveRecord::Base.connection.execute("select profiles.identifier from profiles inner join (select distinct r.id as id, MAX(r.created_at) as created_at from (select from_id, to_id, created_at, (case when from_id=#{user.id} then to_id else from_id end) as id from chat_messages where from_id=#{user.id} or to_id=#{user.id}) as r group by id order by created_at desc, id) as t on profiles.id=t.id order by t.created_at desc").entries.map {|e| e['identifier']} | |
68 | + render :json => conversations_order.to_json | |
69 | + end | |
70 | + | |
66 | 71 | protected |
67 | 72 | |
68 | 73 | def check_environment_feature | ... | ... |