Use modeling hints to remove some items from is:modeling searches

There's still plenty left, but we have 213 we "manually" marked as
"done" (I think I ran a batch job on everything Chips told me was on
the page and already done), and that should help a lot!
This commit is contained in:
Emi Matchu 2024-11-20 11:22:33 -08:00
parent 270b27c1d2
commit e846a75f7a
2 changed files with 53 additions and 1 deletions

View file

@ -31,6 +31,9 @@ class Item < ApplicationRecord
validates :description, :thumbnail_url, :rarity, :price, :zones_restrict, validates :description, :thumbnail_url, :rarity, :price, :zones_restrict,
exclusion: {in: [nil], message: "must be specified"} exclusion: {in: [nil], message: "must be specified"}
after_save :update_cached_fields,
if: :modeling_status_hint_previously_changed?
attr_writer :current_body_id, :owned, :wanted attr_writer :current_body_id, :owned, :wanted
NCRarities = [0, 500] NCRarities = [0, 500]
@ -300,8 +303,16 @@ class Item < ApplicationRecord
write_attribute('species_support_ids', replacement) write_attribute('species_support_ids', replacement)
end end
def modeling_hinted_done?
modeling_status_hint == "done" || modeling_status_hint == "glitchy"
end
def predicted_body_ids def predicted_body_ids
@predicted_body_ids ||= if compatible_body_ids.include?(0) @predicted_body_ids ||= if modeling_hinted_done?
# If we've manually set this item to no longer report as needing modeling,
# predict that the current bodies are all of the compatible bodies.
compatible_body_ids
elsif compatible_body_ids.include?(0)
# Oh, look, it's already known to fit everybody! Sweet. We're done. (This # Oh, look, it's already known to fit everybody! Sweet. We're done. (This
# isn't folded into the case below, in case this item somehow got a # isn't folded into the case below, in case this item somehow got a
# body-specific and non-body-specific asset. In all the cases I've seen # body-specific and non-body-specific asset. In all the cases I've seen

View file

@ -231,5 +231,46 @@ RSpec.describe Item do
expect(item.compatible_body_ids).to contain_exactly(1, 2, 3, 4) expect(item.compatible_body_ids).to contain_exactly(1, 2, 3, 4)
end end
end end
describe "an item without any modeling data, but hinted as done" do
subject(:item) { items(:birthday_bg) }
before { item.update!(modeling_status_hint: :done) }
it_behaves_like "a fully-modeled item"
it("has no compatible body IDs") do
expect(item.compatible_body_ids).to be_empty
end
end
describe "an item with two species modeled, but hinted as done" do
subject(:item) { items(:birthday_bg) }
before do
item.swf_assets << build_item_asset(zones(:wings), body_id: 1)
item.swf_assets << build_item_asset(zones(:wings), body_id: 2)
item.update!(modeling_status_hint: :done)
end
it_behaves_like "a fully-modeled item"
it("has two compatible body IDs") do
expect(item.compatible_body_ids).to contain_exactly(1, 2)
end
end
describe "an item with two species modeled, but hinted as glitchy" do
subject(:item) { items(:birthday_bg) }
before do
item.swf_assets << build_item_asset(zones(:wings), body_id: 1)
item.swf_assets << build_item_asset(zones(:wings), body_id: 2)
item.update!(modeling_status_hint: :glitchy)
end
it_behaves_like "a fully-modeled item"
it("has two compatible body IDs") do
expect(item.compatible_body_ids).to contain_exactly(1, 2)
end
end
end end
end end