mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-05-31 00:41:20 +00:00
Purged git history and removed sensitive information.
This commit is contained in:
commit
6bcc8dc76b
862 changed files with 25312 additions and 0 deletions
25
app/models/matcher.rb
Normal file
25
app/models/matcher.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
class Matcher < ActiveRecord::Base
|
||||
include Extra
|
||||
|
||||
attr_protected :id, :updated_at, :created_at
|
||||
|
||||
belongs_to :match
|
||||
belongs_to :user
|
||||
belongs_to :contester
|
||||
has_many :teams, :through => :contester
|
||||
|
||||
scope :stats,
|
||||
:select => "user_id, COUNT(*) as num, users.username",
|
||||
:joins => "LEFT JOIN users ON users.id = user_id",
|
||||
:group => "user_id",
|
||||
:having => "num > 20",
|
||||
:order => "num DESC"
|
||||
scope :mercs, :conditions => {:merc => true}
|
||||
scope :of_contester,
|
||||
lambda { |contester| {:conditions => {:contester_id => contester.id}} }
|
||||
|
||||
validates_presence_of :match, :user
|
||||
validates_uniqueness_of :user_id, :scope => :match_id
|
||||
validates_inclusion_of :merc, :in => [true, false]
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue