diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2017-08-15 11:27:37 +0100 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2017-09-07 13:01:59 +0100 |
commit | cfd475a45ee2655fa0148b0b561f95b44fe8641b (patch) | |
tree | 84bc8f20239d58ed19e35cb515c50d3b36735c4f /app/models/user.rb | |
parent | d1b60cbc67dc14b21820ef3f823a8e1ea851697d (diff) | |
download | gitlab-ce-cfd475a45ee2655fa0148b0b561f95b44fe8641b.tar.gz |
Removes default scope from sortable23079-remove-default-scope-in-sortable
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index c5b5f09722f..1ac5b029c81 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -70,7 +70,7 @@ class User < ActiveRecord::Base # # Namespace for personal projects - has_one :namespace, -> { where type: nil }, dependent: :destroy, foreign_key: :owner_id, autosave: true # rubocop:disable Cop/ActiveRecordDependent + has_one :namespace, -> { where(type: nil) }, dependent: :destroy, foreign_key: :owner_id, autosave: true # rubocop:disable Cop/ActiveRecordDependent # Profile has_many :keys, -> do @@ -255,11 +255,13 @@ class User < ActiveRecord::Base end def sort(method) - case method.to_s + order_method = method || 'id_desc' + + case order_method.to_s when 'recent_sign_in' then order_recent_sign_in when 'oldest_sign_in' then order_oldest_sign_in else - order_by(method) + order_by(order_method) end end @@ -367,7 +369,7 @@ class User < ActiveRecord::Base # Returns a user for the given SSH key. def find_by_ssh_key_id(key_id) - find_by(id: Key.unscoped.select(:user_id).where(id: key_id)) + Key.find_by(id: key_id)&.user end def find_by_full_path(path, follow_redirects: false) |