Merge pull request #1 from consul/master

Merge 29/09/17
This commit is contained in:
Pedro
2017-09-29 12:06:21 +02:00
committed by GitHub
2 changed files with 9 additions and 9 deletions

View File

@@ -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)

View File

@@ -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