Update missing body ID prediction to handle, say, the Maraquan Mynci.
It turns out that some pets for seemingly nonstandard colors have the standard body type anyway, and vice-versa. This implies that we should stop relying on a color's standardness, but, for the time being, we've just revised the prediction model: Old model: * If I see a body_id, I find the corresponding color_ids, and it's wearable by all pet types with those color_ids. New model: * If I see a body_id, * If it also belongs to a basic pet type, it's a standard body ID. * It therefore fits all pet types of standard color (if there's more than one body ID modeled already). (Not really, because of weird exceptions like Orange Chia. Should that be standard or not?) * If it doesn't also belong to a basic pet type, it's a nonstandard body ID. * It therefore only belongs to one color, and therefore the item fits all pet types of the same color.
This commit is contained in:
parent
fb6df82570
commit
03c76fe882
2 changed files with 47 additions and 41 deletions
|
@ -219,16 +219,12 @@ class Item < ActiveRecord::Base
|
|||
map(&:color_id)
|
||||
end
|
||||
|
||||
def modeled_colors
|
||||
@modeled_colors ||= Color.select([:id, :standard]).find(modeled_color_ids)
|
||||
def basic_body_ids
|
||||
@basic_body_ids ||= begin
|
||||
basic_color_ids ||= Color.select([:id]).basic.map(&:id)
|
||||
PetType.select('DISTINCT body_id').
|
||||
where(color_id: basic_color_ids).map(&:body_id)
|
||||
end
|
||||
|
||||
def modeled_standard_colors?
|
||||
modeled_colors.any?(&:standard)
|
||||
end
|
||||
|
||||
def modeled_nonstandard_colors
|
||||
modeled_colors.reject(&:standard)
|
||||
end
|
||||
|
||||
def predicted_body_ids
|
||||
|
@ -249,10 +245,23 @@ class Item < ActiveRecord::Base
|
|||
# all bodies of the same color. (To my knowledge, anyway. I'm not aware
|
||||
# of any exceptions.) So, let's find those bodies by first finding those
|
||||
# colors.
|
||||
PetType.select('DISTINCT body_id').
|
||||
where(color_id: modeled_color_ids).
|
||||
basic_modeled_body_ids, nonbasic_modeled_body_ids = modeled_body_ids.
|
||||
partition { |bi| basic_body_ids.include?(bi) }
|
||||
|
||||
output = []
|
||||
if basic_modeled_body_ids.present?
|
||||
output += basic_body_ids
|
||||
end
|
||||
if nonbasic_modeled_body_ids.present?
|
||||
nonbasic_modeled_color_ids = PetType.select('DISTINCT color_id').
|
||||
where(body_id: nonbasic_modeled_body_ids).
|
||||
map(&:color_id)
|
||||
output += PetType.select('DISTINCT body_id').
|
||||
where(color_id: nonbasic_modeled_color_ids).
|
||||
map(&:body_id)
|
||||
end
|
||||
output
|
||||
end
|
||||
end
|
||||
|
||||
def predicted_missing_body_ids
|
||||
|
@ -277,7 +286,7 @@ class Item < ActiveRecord::Base
|
|||
|
||||
def predicted_missing_nonstandard_body_pet_types
|
||||
PetType.joins(:color).
|
||||
where(body_id: predicted_missing_body_ids,
|
||||
where(body_id: predicted_missing_body_ids - basic_body_ids,
|
||||
colors: {standard: false})
|
||||
end
|
||||
|
||||
|
|
|
@ -71,10 +71,7 @@
|
|||
= latest_contribution_description(@latest_contribution)
|
||||
%abbr#latest-contribution-created-at{:title => @latest_contribution.created_at.getutc.iso8601}
|
||||
|
||||
|
||||
-#
|
||||
#whats-new
|
||||
-# TODO: i18n all the things
|
||||
#whats-new
|
||||
-# TODO: cache this entire block? or just request newest items every time?
|
||||
- if @newest_unmodeled_items.present?
|
||||
#modeling-neopets-users{'data-usernames' => @neopets_usernames.to_json}
|
||||
|
|
Loading…
Reference in a new issue