diff --git a/app/models/poll.rb b/app/models/poll.rb index 3873ac5e0..24ffa3a06 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -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