Assume new alt styles are "Nostalgic" until the end of 2024

This commit is contained in:
Emi Matchu 2024-05-29 18:46:17 -07:00
parent b06e8a25c0
commit 285cf233f0

View file

@ -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)