Compare commits

...

5 commits

Author SHA1 Message Date
23c083ff1d Use "real" series name field when editing alt styles
Just a little improvement to the form, so when there's no series name,
the text field is empty—even though in most contexts we *pretend* it's
"<New?">
2024-10-18 17:13:16 -07:00
6b7c73870a Stop inferring AltStyle series name, now that it's getting more varied
They're not all Nostalgic anymore! Oh, how the times have changed!

This way, new ones will appear as "<New?>", until support staff come in
and label them (with our cool new tools!)
2024-10-18 17:07:38 -07:00
e7a0ff1234 Make deleting an AltStyle also delete its ParentSwfAssetRelationships
Not relevant in-app as such, I'm just deleting records to re-test
things in development, and it helps to keep things in a more consistent
state!
2024-10-18 17:06:13 -07:00
50c9ba53e7 Add announcement explaining alt style bugs
so people know it's fixed and can model them now lol
2024-10-18 17:04:44 -07:00
89c729ecbe Oops, fix bug preventing new alt styles from being saved
Whoops, I didn't realize this change I made to validation for the alt
style editing form, was goofing up alt style modeling!

The trick is, the validation was happening before the `before_create`
hook. Now I've reformulated these as `before_validation` hooks, so
we're not rejecting new alt styles for having no thumbnail!
2024-10-18 17:04:26 -07:00
6 changed files with 24 additions and 36 deletions

View file

@ -63,7 +63,7 @@ class AltStylesController < ApplicationController
protected protected
def alt_style_params def alt_style_params
params.require(:alt_style).permit(:series_name, :thumbnail_url) params.require(:alt_style).permit(:real_series_name, :thumbnail_url)
end end
def find_color def find_color

View file

@ -1,5 +1,5 @@
module OutfitsHelper module OutfitsHelper
LAST_DAY_OF_ANNOUNCEMENT = Date.parse("2024-10-10") LAST_DAY_OF_ANNOUNCEMENT = Date.parse("2024-10-21")
def show_announcement? def show_announcement?
Date.today <= LAST_DAY_OF_ANNOUNCEMENT Date.today <= LAST_DAY_OF_ANNOUNCEMENT
end end

View file

@ -4,7 +4,7 @@ class AltStyle < ApplicationRecord
belongs_to :species belongs_to :species
belongs_to :color belongs_to :color
has_many :parent_swf_asset_relationships, as: :parent has_many :parent_swf_asset_relationships, as: :parent, dependent: :destroy
has_many :swf_assets, through: :parent_swf_asset_relationships has_many :swf_assets, through: :parent_swf_asset_relationships
has_many :contributions, as: :contributed, inverse_of: :contributed has_many :contributions, as: :contributed, inverse_of: :contributed
@ -12,8 +12,7 @@ class AltStyle < ApplicationRecord
validates :series_name, presence: true, allow_nil: true validates :series_name, presence: true, allow_nil: true
validates :thumbnail_url, presence: true validates :thumbnail_url, presence: true
before_create :infer_series_name before_validation :infer_thumbnail_url, unless: :thumbnail_url?
before_create :infer_thumbnail_url
scope :matching_name, ->(series_name, color_name, species_name) { scope :matching_name, ->(series_name, color_name, species_name) {
color = Color.find_by_name!(color_name) color = Color.find_by_name!(color_name)
@ -36,13 +35,21 @@ class AltStyle < ApplicationRecord
# `fits:<New?>-faerie-draik` intentionally will not work, and the canonical # `fits:<New?>-faerie-draik` intentionally will not work, and the canonical
# filter name will be `fits:alt-style-IDNUMBER`, instead. # filter name will be `fits:alt-style-IDNUMBER`, instead.
def series_name def series_name
self[:series_name] || "<New?>" real_series_name || "<New?>"
end
def real_series_name=(new_series_name)
self[:series_name] = new_series_name
end
def real_series_name
self[:series_name]
end end
# You can use this to check whether `series_name` is returning the actual # You can use this to check whether `series_name` is returning the actual
# value or its placeholder value. # value or its placeholder value.
def has_real_series_name? def real_series_name?
self[:series_name].present? real_series_name.present?
end end
def adjective_name def adjective_name
@ -74,19 +81,6 @@ class AltStyle < ApplicationRecord
end end
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
# At time of writing, most batches of Alt Styles thumbnails used a simple # At time of writing, most batches of Alt Styles thumbnails used a simple
# pattern for the item thumbnail URL, but that's not always the case anymore. # pattern for the item thumbnail URL, but that's not always the case anymore.
# For now, let's keep using this format as the default value when creating a # For now, let's keep using this format as the default value when creating a

View file

@ -367,7 +367,7 @@ class Item
# If the real series name has been set in the database by support # If the real series name has been set in the database by support
# staff, use that for the canonical filter text for this alt style. # staff, use that for the canonical filter text for this alt style.
# Otherwise, represent this alt style by ID. # Otherwise, represent this alt style by ID.
if alt_style.has_real_series_name? if alt_style.real_series_name?
series_name = alt_style.series_name.downcase series_name = alt_style.series_name.downcase
color_name = alt_style.color.name.downcase color_name = alt_style.color.name.downcase
species_name = alt_style.species.name.downcase species_name = alt_style.species.name.downcase

View file

@ -21,8 +21,8 @@
- @alt_style.errors.each do |error| - @alt_style.errors.each do |error|
%li= error.full_message %li= error.full_message
%fieldset %fieldset
= f.label :series_name, "Series" = f.label :real_series_name, "Series"
= f.text_field :series_name = f.text_field :real_series_name
= f.label :thumbnail_url, "Thumbnail" = f.label :thumbnail_url, "Thumbnail"
.thumbnail-field .thumbnail-field
- if @alt_style.thumbnail_url? - if @alt_style.thumbnail_url?

View file

@ -11,19 +11,13 @@
.content .content
%p %p
%strong %strong
= link_to "This week in DTI: Performance upgrades!", 🎃
"https://blog.openneo.net/2024/10/03/perf-upgrades.html" = link_to "New pet styles are out today!", alt_styles_path
If you saw the site stutter, whoops, you weren't imagining it! We've If you've seen one we don't have yet, please model it by entering the
dug into our past and made three changes to speed up the site for pet's name in the box below. Thank you!!
everyone, whew!
%p %p
Also, in case you can help: By the way, we had a bug where modeling new styles wasn't working for a
= succeed "," do little while. Fixed now! 🤞
= link_to "I'm job-hunting right now",
"https://blog.openneo.net/2024/10/03/perf-upgrades.html#job-hunting"
looking for
full-time software roles!
%em (You gotta ask, right?)
#outfit-forms #outfit-forms
#pet-preview #pet-preview