Improved SQL for postgresql.

This commit is contained in:
Martin Edenhofer 2016-04-29 19:52:45 +02:00
parent f19bc39ddf
commit e6540720a3

View file

@ -48,12 +48,12 @@ returns
result = Cti::CallerId.where(
caller_id: caller_id,
level: 'known',
).group(:user_id).order('id DESC').limit(20)
).group(:user_id, :id).order(id: 'DESC').limit(20)
if !result[0]
result = Cti::CallerId.where(
caller_id: caller_id,
level: 'maybe',
).group(:user_id).order('id DESC').limit(20)
).group(:user_id, :id).order(id: 'DESC').limit(20)
end
if !result[0]
result = Cti::CallerId.where(