@@ -251,7 +251,7 @@ GEM
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mimemagic (0.3.2)
|
||||
mini_portile2 (2.2.0)
|
||||
mini_portile2 (2.3.0)
|
||||
minitest (5.10.3)
|
||||
mixlib-cli (1.7.0)
|
||||
mixlib-config (2.2.4)
|
||||
@@ -262,8 +262,8 @@ GEM
|
||||
net-ssh (>= 2.6.5)
|
||||
net-ssh (4.1.0)
|
||||
newrelic_rpm (4.1.0.333)
|
||||
nokogiri (1.8.0)
|
||||
mini_portile2 (~> 2.2.0)
|
||||
nokogiri (1.8.1)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
nori (2.6.0)
|
||||
oauth (0.5.3)
|
||||
oauth2 (1.4.0)
|
||||
|
||||
@@ -16,23 +16,23 @@ class Poll < ActiveRecord::Base
|
||||
|
||||
validate :date_range
|
||||
|
||||
scope :current, -> { where('starts_at <= ? and ? <= ends_at', Time.current, Time.current) }
|
||||
scope :incoming, -> { where('? < starts_at', Time.current) }
|
||||
scope :expired, -> { where('ends_at < ?', Time.current) }
|
||||
scope :current, -> { where('starts_at <= ? and ? <= ends_at', Date.current.beginning_of_day, Date.current.beginning_of_day) }
|
||||
scope :incoming, -> { where('? < starts_at', Date.current.beginning_of_day) }
|
||||
scope :expired, -> { where('ends_at < ?', Date.current.beginning_of_day) }
|
||||
scope :published, -> { where('published = ?', true) }
|
||||
scope :by_geozone_id, ->(geozone_id) { where(geozones: {id: geozone_id}.joins(:geozones)) }
|
||||
|
||||
scope :sort_for_list, -> { order(:geozone_restricted, :starts_at, :name) }
|
||||
|
||||
def current?(timestamp = DateTime.current)
|
||||
def current?(timestamp = Date.current.beginning_of_day)
|
||||
starts_at <= timestamp && timestamp <= ends_at
|
||||
end
|
||||
|
||||
def incoming?(timestamp = DateTime.current)
|
||||
def incoming?(timestamp = Date.current.beginning_of_day)
|
||||
timestamp < starts_at
|
||||
end
|
||||
|
||||
def expired?(timestamp = DateTime.current)
|
||||
def expired?(timestamp = Date.current.beginning_of_day)
|
||||
ends_at < timestamp
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user