Browse Source

feat: update filters automatically year-on-year

pull/2216/head
natdeanlewissoftwire 2 years ago
parent
commit
5cce7d2d46
  1. 4
      app/helpers/collection_time_helper.rb
  2. 10
      app/helpers/filters_helper.rb
  3. 4
      app/services/feature_toggle.rb

4
app/helpers/collection_time_helper.rb

@ -46,6 +46,10 @@ module CollectionTimeHelper
current_collection_start_date - 1.year
end
def twice_previous_collection_start_year
current_collection_start_year - 2
end
def quarter_for_date(date: Time.zone.now)
quarters = [
{ quarter: "Q3", cutoff_date: Time.zone.local(2024, 1, 12), start_date: Time.zone.local(2023, 10, 1), end_date: Time.zone.local(2023, 12, 31) },

10
app/helpers/filters_helper.rb

@ -93,11 +93,11 @@ module FiltersHelper
end
def collection_year_options
if FeatureToggle.collection_2024_2025_year_enabled?
{ "2024": "2024/25", "2023": "2023/24", "2022": "2022/23" }
else
{ "2023": "2023/24", "2022": "2022/23", "2021": "2021/22" }
end
{
current_collection_start_year.to_s => year_combo(current_collection_start_year),
previous_collection_start_year.to_s => year_combo(previous_collection_start_year),
twice_previous_collection_start_year.to_s => year_combo(twice_previous_collection_start_year),
}
end
def filters_applied_text(filter_type)

4
app/services/feature_toggle.rb

@ -1,8 +1,4 @@
class FeatureToggle
def self.collection_2024_2025_year_enabled?
!Rails.env.production?
end
# Disable check on preview apps to allow for testing of future forms
def self.saledate_collection_window_validation_enabled?
Rails.env.production? || Rails.env.test? || Rails.env.staging?

Loading…
Cancel
Save