From ebff9d3625ddb1afb5c5e764c75a9e2d51758cfe Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Wed, 8 Jan 2020 10:34:01 -0500 Subject: [PATCH] GRN2-xx: Fixed issue with rooms not being ordered correctly (#897) * Fixed issue with rooms not being ordered correctly * removed home room from list Co-authored-by: Jesus Federico --- app/models/user.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 3ab10b23..4cae3de9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -131,10 +131,8 @@ class User < ApplicationRecord # Retrives a list of all a users rooms that are not the main room, sorted by last session date. def secondary_rooms - secondary = (rooms - [main_room]) - no_session, session = secondary.partition { |r| r.last_session.nil? } - sorted = session.sort_by(&:last_session) - sorted + no_session + room_list = rooms.where.not(uid: main_room.uid) + room_list.where.not(last_session: nil).order("last_session desc") + room_list.where(last_session: nil) end def name_chunk