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)
|
map(&:color_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def modeled_colors
|
def basic_body_ids
|
||||||
@modeled_colors ||= Color.select([:id, :standard]).find(modeled_color_ids)
|
@basic_body_ids ||= begin
|
||||||
end
|
basic_color_ids ||= Color.select([:id]).basic.map(&:id)
|
||||||
|
PetType.select('DISTINCT body_id').
|
||||||
def modeled_standard_colors?
|
where(color_id: basic_color_ids).map(&:body_id)
|
||||||
modeled_colors.any?(&:standard)
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def modeled_nonstandard_colors
|
|
||||||
modeled_colors.reject(&:standard)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def predicted_body_ids
|
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
|
# 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
|
# of any exceptions.) So, let's find those bodies by first finding those
|
||||||
# colors.
|
# colors.
|
||||||
PetType.select('DISTINCT body_id').
|
basic_modeled_body_ids, nonbasic_modeled_body_ids = modeled_body_ids.
|
||||||
where(color_id: modeled_color_ids).
|
partition { |bi| basic_body_ids.include?(bi) }
|
||||||
map(&:body_id)
|
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -277,7 +286,7 @@ class Item < ActiveRecord::Base
|
||||||
|
|
||||||
def predicted_missing_nonstandard_body_pet_types
|
def predicted_missing_nonstandard_body_pet_types
|
||||||
PetType.joins(:color).
|
PetType.joins(:color).
|
||||||
where(body_id: predicted_missing_body_ids,
|
where(body_id: predicted_missing_body_ids - basic_body_ids,
|
||||||
colors: {standard: false})
|
colors: {standard: false})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -71,33 +71,30 @@
|
||||||
= latest_contribution_description(@latest_contribution)
|
= latest_contribution_description(@latest_contribution)
|
||||||
%abbr#latest-contribution-created-at{:title => @latest_contribution.created_at.getutc.iso8601}
|
%abbr#latest-contribution-created-at{:title => @latest_contribution.created_at.getutc.iso8601}
|
||||||
|
|
||||||
|
#whats-new
|
||||||
-#
|
-# TODO: cache this entire block? or just request newest items every time?
|
||||||
#whats-new
|
- if @newest_unmodeled_items.present?
|
||||||
-# TODO: i18n all the things
|
#modeling-neopets-users{'data-usernames' => @neopets_usernames.to_json}
|
||||||
-# TODO: cache this entire block? or just request newest items every time?
|
%h3= t '.newest_items.unmodeled.header'
|
||||||
- if @newest_unmodeled_items.present?
|
%ul#newest-unmodeled-items
|
||||||
#modeling-neopets-users{'data-usernames' => @neopets_usernames.to_json}
|
- @newest_unmodeled_items.each do |item|
|
||||||
%h3= t '.newest_items.unmodeled.header'
|
- localized_cache "items/#{item.id} modeling_progress updated_at=#{item.updated_at.to_i}" do
|
||||||
%ul#newest-unmodeled-items
|
%li{'data-item-id' => item.id}
|
||||||
- @newest_unmodeled_items.each do |item|
|
= link_to image_tag(item.thumbnail_url), item, :class => 'image-link'
|
||||||
- localized_cache "items/#{item.id} modeling_progress updated_at=#{item.updated_at.to_i}" do
|
= link_to item, :class => 'header' do
|
||||||
%li{'data-item-id' => item.id}
|
%h2= item.name
|
||||||
= link_to image_tag(item.thumbnail_url), item, :class => 'image-link'
|
%span.meter{style: "width: #{@newest_unmodeled_items_predicted_modeled_ratio[item]*100}%"}
|
||||||
= link_to item, :class => 'header' do
|
.missing-bodies
|
||||||
%h2= item.name
|
= render_predicted_missing_species_by_color(@newest_unmodeled_items_predicted_missing_species_by_color[item])
|
||||||
%span.meter{style: "width: #{@newest_unmodeled_items_predicted_modeled_ratio[item]*100}%"}
|
.models
|
||||||
.missing-bodies
|
- if @newest_modeled_items.present?
|
||||||
= render_predicted_missing_species_by_color(@newest_unmodeled_items_predicted_missing_species_by_color[item])
|
%h3= t '.newest_items.modeled.header'
|
||||||
.models
|
%ul#newest-modeled-items
|
||||||
- if @newest_modeled_items.present?
|
- @newest_modeled_items.each do |item|
|
||||||
%h3= t '.newest_items.modeled.header'
|
%li.object
|
||||||
%ul#newest-modeled-items
|
= link_to item, title: item.name, alt: item.name do
|
||||||
- @newest_modeled_items.each do |item|
|
= image_tag item.thumbnail_url
|
||||||
%li.object
|
= nc_icon_for(item)
|
||||||
= 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
|
- localized_cache :action_suffix => 'templates' do
|
||||||
|
|
Loading…
Reference in a new issue