From a29975bbf98a45d75bfde09915c9e5cdb6bb0c8b Mon Sep 17 00:00:00 2001 From: Kat Date: Thu, 14 Jul 2022 14:34:43 +0100 Subject: [PATCH] Compare date instead of time --- app/models/form/setup/questions/location_id.rb | 2 +- app/models/form/setup/questions/scheme_id.rb | 2 +- app/models/scheme.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/form/setup/questions/location_id.rb b/app/models/form/setup/questions/location_id.rb index 18fd765ef..dae770a0d 100644 --- a/app/models/form/setup/questions/location_id.rb +++ b/app/models/form/setup/questions/location_id.rb @@ -13,7 +13,7 @@ class Form::Setup::Questions::LocationId < ::Form::Question answer_opts = {} return answer_opts unless ActiveRecord::Base.connected? - Location.select(:id, :postcode, :name).where("startdate <= ? or startdate IS NULL", Time.zone.now).each_with_object(answer_opts) do |location, hsh| + Location.select(:id, :postcode, :name).where("startdate <= ? or startdate IS NULL", Date.today).each_with_object(answer_opts) do |location, hsh| hsh[location.id.to_s] = { "value" => location.postcode, "hint" => location.name } hsh end diff --git a/app/models/form/setup/questions/scheme_id.rb b/app/models/form/setup/questions/scheme_id.rb index e446ebb57..424be0c9a 100644 --- a/app/models/form/setup/questions/scheme_id.rb +++ b/app/models/form/setup/questions/scheme_id.rb @@ -22,7 +22,7 @@ class Form::Setup::Questions::SchemeId < ::Form::Question def displayed_answer_options(case_log) return {} unless case_log.created_by - user_org_scheme_ids = Scheme.select(:id).where(owning_organisation_id: case_log.created_by.organisation_id).joins(:locations).merge(Location.where("startdate <= ? or startdate IS NULL", Time.zone.now)).map(&:id) + user_org_scheme_ids = Scheme.select(:id).where(owning_organisation_id: case_log.created_by.organisation_id).joins(:locations).merge(Location.where("startdate <= ? or startdate IS NULL", Date.today)).map(&:id) answer_options.select do |k, _v| user_org_scheme_ids.include?(k.to_i) end diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 48bfb7890..98f0b2dcf 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -148,7 +148,7 @@ class Scheme < ApplicationRecord end def appended_text - "(#{locations.count { |location| location.startdate.blank? || location.startdate <= Time.now }} locations)" + "(#{locations.count { |location| location.startdate.blank? || location.startdate <= Date.today }} locations)" end def hint