Fixed order of rooms in postgres (#979)

Co-authored-by: Jesus Federico <jesus@123it.ca>
This commit is contained in:
Ahmad Farhat 2020-03-04 09:50:06 -05:00 committed by GitHub
parent 037e4f1c43
commit 43911b9fd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -103,9 +103,9 @@ class User < ApplicationRecord
order(Arel.sql("#{column} #{direction}"))
end
# Returns a list of rooms ordered by last session
# Returns a list of rooms ordered by last session (with nil rooms last)
def ordered_rooms
[main_room] + rooms.where.not(id: main_room.id).order("last_session desc")
[main_room] + rooms.where.not(id: main_room.id).order(Arel.sql("last_session IS NULL, last_session desc"))
end
# Activates an account and initialize a users main room