commit: 1215ab57ff921a4ae72a26f6c033240354bf31fd
parent: a706f1af0486616181b2645615e5ff305f1bbdd6
Author: Eugen Rochko <eugen@zeonfederated.com>
Date: Sat, 24 Sep 2016 14:59:52 +0200
Some extra scopes for user sorting
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/app/models/user.rb b/app/models/user.rb
@@ -8,6 +8,9 @@ class User < ApplicationRecord
has_many :oauth_applications, class_name: 'Doorkeeper::Application', as: :owner
+ scope :prolific, -> { joins('inner join statuses on statuses.account_id = users.account_id').select('users.*, count(statuses.id) as statuses_count').group('users.id').order('statuses_count desc') }
+ scope :recent, -> { order('created_at desc') }
+
def admin?
self.admin
end