From 285cf233f08503b8604ab03610572ac3129c7deb Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Wed, 29 May 2024 18:46:17 -0700 Subject: [PATCH] Assume new alt styles are "Nostalgic" until the end of 2024 --- app/models/alt_style.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/models/alt_style.rb b/app/models/alt_style.rb index aee51809..5eccdee1 100644 --- a/app/models/alt_style.rb +++ b/app/models/alt_style.rb @@ -10,6 +10,8 @@ class AltStyle < ApplicationRecord validates :body_id, presence: true + before_create :infer_series_name + scope :matching_name, ->(series_name, color_name, species_name) { color = Color.find_by_name!(color_name) species = Species.find_by_name!(species_name) @@ -76,6 +78,19 @@ class AltStyle < ApplicationRecord end end + # Until the end of 2024, assume new alt styles are from the "Nostalgic" + # series. That way, we can stop having to manually label them all as they + # come out and get modeled (TNT is prolific rn!), but we aren't gonna get too + # greedy and forget about this and use Nostalgic for some far-future thing, + # in ways that will certainly be fixable but would also be confusing and + # embarrassing. + NOSTALGIC_FINAL_DAY = Date.new(2024, 12, 31) + def infer_series_name + if !has_real_series_name? && Date.today <= NOSTALGIC_FINAL_DAY + self.series_name = "Nostalgic" + end + end + # For convenience in the console! def self.find_by_name(color_name, species_name) color = Color.find_by_name(color_name)