forked from OpenNeo/impress
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)
|
||||
end
|
||||
|
||||
def modeled_standard_colors?
|
||||
modeled_colors.any?(&:standard)
|
||||
end
|
||||
|
||||
def modeled_nonstandard_colors
|
||||
modeled_colors.reject(&:standard)
|
||||
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
|
||||
end
|
||||
|
||||
def predicted_body_ids
|
||||
|
@ -249,9 +245,22 @@ 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).
|
||||
map(&:body_id)
|
||||
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
|
||||
|
||||
|
@ -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,33 +71,30 @@
|
|||
= latest_contribution_description(@latest_contribution)
|
||||
%abbr#latest-contribution-created-at{:title => @latest_contribution.created_at.getutc.iso8601}
|
||||
|
||||
|
||||
-#
|
||||
#whats-new
|
||||
-# TODO: i18n all the things
|
||||
-# 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}
|
||||
%h3= t '.newest_items.unmodeled.header'
|
||||
%ul#newest-unmodeled-items
|
||||
- @newest_unmodeled_items.each do |item|
|
||||
- localized_cache "items/#{item.id} modeling_progress updated_at=#{item.updated_at.to_i}" do
|
||||
%li{'data-item-id' => item.id}
|
||||
= link_to image_tag(item.thumbnail_url), item, :class => 'image-link'
|
||||
= link_to item, :class => 'header' do
|
||||
%h2= item.name
|
||||
%span.meter{style: "width: #{@newest_unmodeled_items_predicted_modeled_ratio[item]*100}%"}
|
||||
.missing-bodies
|
||||
= render_predicted_missing_species_by_color(@newest_unmodeled_items_predicted_missing_species_by_color[item])
|
||||
.models
|
||||
- if @newest_modeled_items.present?
|
||||
%h3= t '.newest_items.modeled.header'
|
||||
%ul#newest-modeled-items
|
||||
- @newest_modeled_items.each do |item|
|
||||
%li.object
|
||||
= link_to item, title: item.name, alt: item.name do
|
||||
= image_tag item.thumbnail_url
|
||||
= nc_icon_for(item)
|
||||
#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}
|
||||
%h3= t '.newest_items.unmodeled.header'
|
||||
%ul#newest-unmodeled-items
|
||||
- @newest_unmodeled_items.each do |item|
|
||||
- localized_cache "items/#{item.id} modeling_progress updated_at=#{item.updated_at.to_i}" do
|
||||
%li{'data-item-id' => item.id}
|
||||
= link_to image_tag(item.thumbnail_url), item, :class => 'image-link'
|
||||
= link_to item, :class => 'header' do
|
||||
%h2= item.name
|
||||
%span.meter{style: "width: #{@newest_unmodeled_items_predicted_modeled_ratio[item]*100}%"}
|
||||
.missing-bodies
|
||||
= render_predicted_missing_species_by_color(@newest_unmodeled_items_predicted_missing_species_by_color[item])
|
||||
.models
|
||||
- if @newest_modeled_items.present?
|
||||
%h3= t '.newest_items.modeled.header'
|
||||
%ul#newest-modeled-items
|
||||
- @newest_modeled_items.each do |item|
|
||||
%li.object
|
||||
= link_to item, title: item.name, alt: item.name do
|
||||
= image_tag item.thumbnail_url
|
||||
= nc_icon_for(item)
|
||||
|
||||
|
||||
- localized_cache :action_suffix => 'templates' do
|
||||
|
|
Loading…
Reference in a new issue