Don't include current polls in recounting polls

On the day when a poll ends, it was considered both current and
recounting.
This commit is contained in:
Javi Martín
2022-09-07 19:44:23 +02:00
parent 2153bd9e98
commit 3543767951
2 changed files with 2 additions and 2 deletions

View File

@@ -44,7 +44,7 @@ class Poll < ApplicationRecord
scope :for, ->(element) { where(related: element) }
scope :current, -> { where("starts_at <= ? and ? <= ends_at", Date.current.beginning_of_day, Date.current.beginning_of_day) }
scope :expired, -> { where("ends_at < ?", Date.current.beginning_of_day) }
scope :recounting, -> { where(ends_at: (Date.current.beginning_of_day - RECOUNT_DURATION)..Date.current.beginning_of_day) }
scope :recounting, -> { 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)) }
scope :public_for_api, -> { all }

View File

@@ -358,7 +358,7 @@ describe Poll do
describe ".recounting" do
it "returns polls in recount & scrutiny phase" do
about_to_start = create(:poll, starts_at: Date.tomorrow)
about_to_end = create(:poll, ends_at: Date.tomorrow)
about_to_end = create(:poll, ends_at: Date.current)
just_ended = create(:poll, ends_at: Date.yesterday)
recounting_ended = create(:poll, starts_at: 3.years.ago, ends_at: 2.years.ago)