Oops, improve series name parsing in Styling Studio auto-importer

Ahh right, that's part of why I skipped Prismatics: it's no longer true
that the first word of the style is its series name.

In this change, I try to parse out everything before the pet name part
of the style name, and default to skipping it if we can't quite get it
right.
This commit is contained in:
Emi Matchu 2024-12-29 15:26:26 -08:00
parent ab572b6576
commit 2f090f3924

View file

@ -55,13 +55,18 @@ namespace "neopets:import" do
"#{record.thumbnail_url.inspect} -> #{style[:image].inspect}"
end
new_series_name = style[:name].match(/\A\S+/)[0] # first word
if !record.real_series_name?
record.series_name = new_series_name
puts "✅ [#{label}]: Series name is now #{new_series_name.inspect}"
elsif record.series_name != new_series_name
puts "⚠️ [#{label}: Series name may have changed, handle manually? " +
"#{record.series_name.inspect} -> #{new_series_name.inspect}"
if style[:name].end_with?(record.pet_name)
new_series_name = style[:name].split(record.pet_name).first.strip
if !record.real_series_name?
record.series_name = new_series_name
puts "✅ [#{label}]: Series name is now #{new_series_name.inspect}"
elsif record.series_name != new_series_name
puts "⚠️ [#{label}: Series name may have changed, handle manually? " +
"#{record.series_name.inspect} -> #{new_series_name.inspect}"
end
else
puts "⚠️ [#{label}: Unable to detect series name, handle manually? " +
"#{record.full_name.inspect} -> #{style[:name].inspect}"
end
if record.changed?