Add recounting Poll scope with trait and spec

This commit is contained in:
Bertocq
2017-10-13 16:48:25 +02:00
parent 540e12a3ac
commit ca2d9a1d68
3 changed files with 22 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ class Poll < ActiveRecord::Base
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 :recounting, -> { Poll.where(ends_at: (Date.current.beginning_of_day - RECOUNT_DURATION)..Date.current.beginning_of_day) }
scope :published, -> { where('published = ?', true) }
scope :by_geozone_id, ->(geozone_id) { where(geozones: {id: geozone_id}.joins(:geozones)) }