aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/request_classification.rb
blob: 678b6cd168717b39da438d93a9a4fa2d1c9e8994 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class RequestClassification < ActiveRecord::Base
    belongs_to :user

    # return classification instances representing the top n
    # users, with a 'cnt' attribute representing the number
    # of classifications the user has made.
    def RequestClassification.league_table(size, conditions=[])
        find(:all, :select => 'user_id, count(*) as cnt',
                                         :conditions => conditions,
                                         :group => 'user_id',
                                         :order => 'cnt desc',
                                         :limit => size,
                                         :include => :user)
    end

end