From 5f97f2fc4de3ca3d8e4466496b81ac6283c78627 Mon Sep 17 00:00:00 2001 From: Mark Hendriksen Date: Mon, 22 Sep 2025 09:21:06 +0200 Subject: [PATCH] Add new date format and 10-year period option (#154) Added 'YYYYMMDD' to supported date formats in Family model. Introduced a 'last_10_years' period option in Period model with appropriate labels and date range. --- app/models/family.rb | 3 ++- app/models/period.rb | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/family.rb b/app/models/family.rb index 4340e785f..c8e8bb00e 100644 --- a/app/models/family.rb +++ b/app/models/family.rb @@ -10,7 +10,8 @@ class Family < ApplicationRecord [ "YYYY/MM/DD", "%Y/%m/%d" ], [ "MM/DD/YYYY", "%m/%d/%Y" ], [ "D/MM/YYYY", "%e/%m/%Y" ], - [ "YYYY.MM.DD", "%Y.%m.%d" ] + [ "YYYY.MM.DD", "%Y.%m.%d" ], + [ "YYYYMMDD", "%Y%m%d" ] ].freeze has_many :users, dependent: :destroy diff --git a/app/models/period.rb b/app/models/period.rb index a1a4dea26..183c6ef8c 100644 --- a/app/models/period.rb +++ b/app/models/period.rb @@ -63,6 +63,12 @@ class Period label_short: "5Y", label: "Last 5 Years", comparison_label: "vs. 5 years ago" + }, + "last_10_years" => { + date_range: -> { [ 10.years.ago.to_date, Date.current ] }, + label_short: "10Y", + label: "Last 10 Years", + comparison_label: "vs. 10 years ago" } }