aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/request_classification.rb
blob: 478a543d39afa06c3413d85a82fcb7bcd370ef54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# == Schema Information
#
# Table name: request_classifications
#
#  id                    :integer          not null, primary key
#  user_id               :integer
#  info_request_event_id :integer
#  created_at            :datetime         not null
#  updated_at            :datetime         not null
#

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