From 1215ab57ff921a4ae72a26f6c033240354bf31fd Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 24 Sep 2016 14:59:52 +0200 Subject: [PATCH] Some extra scopes for user sorting --- app/models/user.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 71e310cc8..066e376f4 100644 --- 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