From 4be034cf8a155fe594f56839aab0ffd80b45b632 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Tue, 21 Mar 2023 10:37:49 +0000 Subject: [PATCH] feat: update scheme typeahead text --- app/models/scheme.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 3a718c25a..f887d2ea5 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -166,7 +166,9 @@ class Scheme < ApplicationRecord end def appended_text - "#{locations.count { |location| location.startdate.blank? || location.startdate <= Time.zone.today }} locations" + active_count = locations.count { |location| %i[active deactivating_soon].include?(location.status) } + inactive_count = locations.count { |location| !%i[active deactivating_soon].include?(location.status) } + "#{active_count} active #{'location'.pluralize(active_count)}, #{inactive_count} inactive #{'location'.pluralize(inactive_count)}" end def hint