mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-26 04:21:36 +00:00
Fix more scopes
This commit is contained in:
parent
143e364812
commit
160d29a569
8 changed files with 39 additions and 21 deletions
18
Gemfile.lock
18
Gemfile.lock
|
@ -54,6 +54,7 @@ GEM
|
|||
activerecord (>= 3.2, < 7.0)
|
||||
rake (>= 10.4, < 14.0)
|
||||
arel (6.0.4)
|
||||
ast (2.4.0)
|
||||
bbcoder (1.0.1)
|
||||
better_errors (2.6.0)
|
||||
coderay (>= 1.0.0)
|
||||
|
@ -163,6 +164,7 @@ GEM
|
|||
i18n-country-translations (~> 1.0, >= 1.3.0)
|
||||
unicode_utils (~> 1.0, >= 1.0.0)
|
||||
i18n_data (0.10.0)
|
||||
jaro_winkler (1.5.4)
|
||||
jquery-rails (2.0.3)
|
||||
railties (>= 3.1.0, < 5.0)
|
||||
thor (~> 0.14)
|
||||
|
@ -197,6 +199,9 @@ GEM
|
|||
nokogiri (1.9.1)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
os (0.9.6)
|
||||
parallel (1.19.1)
|
||||
parser (2.7.0.4)
|
||||
ast (~> 2.4.0)
|
||||
phantomjs (2.1.1.0)
|
||||
poltergeist (1.6.0)
|
||||
capybara (~> 2.1)
|
||||
|
@ -246,6 +251,7 @@ GEM
|
|||
activesupport (= 4.2.11.1)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rainbow (3.0.0)
|
||||
rake (10.5.0)
|
||||
rb-fsevent (0.10.3)
|
||||
rb-inotify (0.10.1)
|
||||
|
@ -258,6 +264,7 @@ GEM
|
|||
actionpack (>= 4.2.0, < 6.0)
|
||||
railties (>= 4.2.0, < 6.0)
|
||||
retriable (3.1.2)
|
||||
rexml (3.2.4)
|
||||
rmagick (4.0.0)
|
||||
rspec (3.3.0)
|
||||
rspec-core (~> 3.3.0)
|
||||
|
@ -280,6 +287,15 @@ GEM
|
|||
rspec-mocks (~> 3.3.0)
|
||||
rspec-support (~> 3.3.0)
|
||||
rspec-support (3.3.0)
|
||||
rubocop (0.80.1)
|
||||
jaro_winkler (~> 1.5.1)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.7.0.1)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
rexml
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 1.4.0, < 1.7)
|
||||
ruby-progressbar (1.10.1)
|
||||
rubyzip (1.3.0)
|
||||
sanitize (2.1.1)
|
||||
nokogiri (>= 1.4.4)
|
||||
|
@ -334,6 +350,7 @@ GEM
|
|||
uglifier (2.5.3)
|
||||
execjs (>= 0.3.0)
|
||||
json (>= 1.8.0)
|
||||
unicode-display_width (1.6.1)
|
||||
unicode_utils (1.4.0)
|
||||
unread (0.10.1)
|
||||
activerecord (>= 3)
|
||||
|
@ -397,6 +414,7 @@ DEPENDENCIES
|
|||
rmagick
|
||||
rspec
|
||||
rspec-rails (~> 3.3.3)
|
||||
rubocop
|
||||
sanitize (~> 2.1.0)
|
||||
sass-rails (~> 5.0.3)
|
||||
selenium-webdriver
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
|
||||
class GatherServer < ActiveRecord::Base
|
||||
scope :ordered, :order => "votes DESC"
|
||||
scope :ordered, -> { order("votes DESC") }
|
||||
|
||||
belongs_to :gather
|
||||
belongs_to :server
|
||||
|
|
|
@ -19,9 +19,9 @@ class Map < ActiveRecord::Base
|
|||
|
||||
has_and_belongs_to_many :contests
|
||||
|
||||
scope :basic, :conditions => {:deleted => false}, :order => "name"
|
||||
scope :with_name, lambda { |name| {:conditions => {:name => name}} }
|
||||
scope :classic, :conditions => "name LIKE 'ns_%'"
|
||||
scope :basic, -> { where(deleted: false).order("name") }
|
||||
scope :with_name, -> (name) { where(name: name) }
|
||||
scope :classic, -> { where("name LIKE 'ns_%'") }
|
||||
scope :of_category,
|
||||
lambda { |category| {
|
||||
:conditions => {:category_id => category.id} }}
|
||||
|
|
|
@ -21,15 +21,14 @@ class Matcher < ActiveRecord::Base
|
|||
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}} }
|
||||
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, -> { where(merc: true) }
|
||||
scope :of_contester, -> (contester) { where(contester_id: contester.id) }
|
||||
|
||||
validates_presence_of :match, :user
|
||||
validates_uniqueness_of :user_id, :scope => :match_id
|
||||
|
|
|
@ -23,7 +23,9 @@ class Message < ActiveRecord::Base
|
|||
validates_length_of :title, :in => 1..100
|
||||
validates_length_of :text, :in => 1..65000
|
||||
|
||||
scope :ordered, :order => "created_at DESC"
|
||||
scope :ordered, -> { order("created_at DESC") }
|
||||
|
||||
# FIXME: check before removing, provided by unread
|
||||
#scope :read_by,
|
||||
# lambda { |user| {:include => :readings, :conditions => ["readings.user_id = ?", user.id]} }
|
||||
#scope :unread_by,
|
||||
|
|
|
@ -32,10 +32,9 @@ class Movie < ActiveRecord::Base
|
|||
attr_protected :id, :updated_at, :created_at
|
||||
attr_accessor :user_name, :name, :stream_ip, :stream_port
|
||||
|
||||
scope :recent, :limit => 5
|
||||
scope :ordered,
|
||||
:include => "file",
|
||||
:order => "data_files.created_at DESC"
|
||||
scope :recent, -> { limit(5) }
|
||||
scope :ordered, -> { include("file").
|
||||
order("data_files.created_at DESC") }
|
||||
scope :index, -> {
|
||||
select("movies.*, users.username, AVG(rates.score) as total_ratings")
|
||||
.joins("LEFT JOIN data_files ON movies.file_id = data_files.id
|
||||
|
@ -43,7 +42,7 @@ class Movie < ActiveRecord::Base
|
|||
LEFT JOIN ratings ON rateable_id = data_files.id AND rateable_type = 'DataFile'
|
||||
LEFT JOIN rates ON ratings.rate_id = rates.id")
|
||||
.group("movies.id") }
|
||||
scope :active_streams, :conditions => "status > 0"
|
||||
scope :active_streams, -> { where("status > 0") }
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :file, :class_name => "DataFile"
|
||||
|
|
|
@ -22,7 +22,7 @@ class Prediction < ActiveRecord::Base
|
|||
validates_inclusion_of :score2, :in => 0..99, :message => "Invalid score"
|
||||
validates_uniqueness_of :match_id, :scope => :user_id
|
||||
|
||||
scope :with_contest, :include => {:match => :contest}
|
||||
scope :with_contest, -> { include({:match => :contest}) }
|
||||
|
||||
belongs_to :match
|
||||
belongs_to :user
|
||||
|
|
|
@ -20,7 +20,7 @@ class Week < ActiveRecord::Base
|
|||
validates_presence_of :contest, :map1, :map2
|
||||
validates_length_of :name, :in => 1..30
|
||||
|
||||
scope :ordered, :order => "start_date ASC"
|
||||
scope :ordered, -> { order("start_date ASC") }
|
||||
|
||||
belongs_to :contest
|
||||
belongs_to :map1, :class_name => "Map"
|
||||
|
|
Loading…
Reference in a new issue