Remove needed items form on Modeling Hub

I think this has just been broken for a long time? And I don't think
it's very useful in a world 15 years later, where our problem *used* to
be giant gaps in our library, which isn't really our data problem
anymore.
This commit is contained in:
Emi Matchu 2024-09-09 18:56:39 -07:00
parent a315282b70
commit a14c4fca48
12 changed files with 59 additions and 344 deletions

View file

@ -1,116 +1,5 @@
var DEBUG = document.location.search.substr(0, 6) == "?debug"; var DEBUG = document.location.search.substr(0, 6) == "?debug";
function petThumbnailUrl(pet_name) {
// if first character is "@", use the hash url
if (pet_name[0] == "@") {
return "https://pets.neopets.com/cp/" + pet_name.substr(1) + "/1/1.png";
}
return "https://pets.neopets.com/cpn/" + pet_name + "/1/1.png";
}
/* Needed items form */
(function () {
var UI = {};
UI.form = $("#needed-items-form");
UI.alert = $("#needed-items-alert");
UI.pet_name_field = $("#needed-items-pet-name-field");
UI.pet_thumbnail = $("#needed-items-pet-thumbnail");
UI.pet_header = $("#needed-items-pet-header");
UI.reload = $("#needed-items-reload");
UI.pet_items = $("#needed-items-pet-items");
UI.item_template = $("#item-template");
var current_request = { abort: function () {} };
function sendRequest(options) {
current_request = $.ajax(options);
}
function cancelRequest() {
if (DEBUG) console.log("Canceling request", current_request);
current_request.abort();
}
/* Pet */
var last_successful_pet_name = null;
function loadPet(pet_name) {
// If there is a request in progress, kill it. Our new pet request takes
// priority, and, if I submit a name while the previous name is loading, I
// don't want to process both responses.
cancelRequest();
sendRequest({
url: UI.form.attr("action") + ".json",
dataType: "json",
data: { name: pet_name },
error: petError,
success: function (data) {
petSuccess(data, pet_name);
},
complete: petComplete,
});
UI.form.removeClass("failed").addClass("loading-pet");
}
function petComplete() {
UI.form.removeClass("loading-pet");
}
function petError(xhr) {
UI.alert.text(xhr.responseText);
UI.form.addClass("failed");
}
function petSuccess(data, pet_name) {
last_successful_pet_name = pet_name;
UI.pet_thumbnail.attr("src", petThumbnailUrl(pet_name));
UI.pet_header.empty();
$("#needed-items-pet-header-template")
.tmpl({ pet_name: pet_name })
.appendTo(UI.pet_header);
loadItems(data.query);
}
/* Items */
function loadItems(query) {
UI.form.addClass("loading-items");
sendRequest({
url: "/items/needed.json",
dataType: "json",
data: query,
success: itemsSuccess,
});
}
function itemsSuccess(items) {
if (DEBUG) {
// The dev server is missing lots of data, so sends me 2000+ needed
// items. We don't need that many for styling, so limit it to 100 to make
// my browser happier.
items = items.slice(0, 100);
}
UI.pet_items.empty();
UI.item_template.tmpl(items).appendTo(UI.pet_items);
UI.form.removeClass("loading-items").addClass("loaded");
}
UI.form.submit(function (e) {
e.preventDefault();
loadPet(UI.pet_name_field.val());
});
UI.reload.click(function (e) {
e.preventDefault();
loadPet(last_successful_pet_name);
});
})();
/* Bulk pets form */ /* Bulk pets form */
(function () { (function () {
var form = $("#bulk-pets-form"), var form = $("#bulk-pets-form"),
@ -122,6 +11,15 @@ function petThumbnailUrl(pet_name) {
$(document.body).addClass("js"); $(document.body).addClass("js");
function petThumbnailUrl(pet_name) {
// if first character is "@", use the hash url
if (pet_name[0] == "@") {
return "https://pets.neopets.com/cp/" + pet_name.substr(1) + "/1/1.png";
}
return "https://pets.neopets.com/cpn/" + pet_name + "/1/1.png";
}
bulk_load_queue = new (function BulkLoadQueue() { bulk_load_queue = new (function BulkLoadQueue() {
var RECENTLY_SENT_INTERVAL_IN_SECONDS = 30; var RECENTLY_SENT_INTERVAL_IN_SECONDS = 30;
var RECENTLY_SENT_MAX = 3; var RECENTLY_SENT_MAX = 3;

View file

@ -2,70 +2,8 @@
@import "../partials/clean/mixins" @import "../partials/clean/mixins"
body.pets-bulk body.pets-bulk
#needed-items-form, #bulk-pets-form
text-align: center
#needed-items-form
#needed-items-pet
border-top: 1px solid $soft-border-color
display: none
margin-top: 1em
padding-top: 1em
h4
font-size: 150%
margin-bottom: .5em
#needed-items-reload
+inline-block
font-size: 12px
margin-left: 1em
vertical-align: middle
#needed-items-alert
display: none
margin-top: .5em
#needed-items-pet-thumbnail
height: 50px
width: 50px
#needed-items-pet-items
li.owned
background: $module-bg-color
border: 1px solid $module-border-color
.object-owned
color: $soft-text-color
display: block
font-size: 75%
font-style: italic
padding-bottom: .25em
&.loading-pet, &.loading-items
#needed-items-pet-name-field
background:
image: image-url("loading.gif")
position: center right
repeat: no-repeat
#needed-items-pet-items
+opacity(.50)
&.loading-pet
#needed-items-pet h4
+opacity(.50)
&.loaded
#needed-items-pet
display: block
&.failed
#needed-items-alert
display: block
#bulk-pets-form #bulk-pets-form
border-top: 1px solid $module-border-color text-align: center
margin-top: 12px margin-top: 12px
padding-top: 12px padding-top: 12px

View file

@ -112,27 +112,6 @@ class ItemsController < ApplicationController
end end
end end
def needed
if params[:color] && params[:species]
@pet_type = PetType.find_by_color_id_and_species_id(
params[:color],
params[:species]
)
end
unless @pet_type
raise ActiveRecord::RecordNotFound, 'Pet type not found'
end
@items = @pet_type.needed_items.order(:name)
assign_closeted!(@items)
respond_to do |format|
format.html { @pet_name = params[:name] ; render :layout => 'application' }
format.json { render :json => @items }
end
end
def sources def sources
# Load all the items, then group them by source. # Load all the items, then group them by source.
item_ids = params[:ids].split(",") item_ids = params[:ids].split(",")

View file

@ -39,7 +39,6 @@ class PetsController < ApplicationController
def destination def destination
case (params[:destination] || params[:origin]) case (params[:destination] || params[:origin])
when 'wardrobe' then wardrobe_path when 'wardrobe' then wardrobe_path
when 'needed_items' then needed_items_path
else root_path else root_path
end end
end end

View file

@ -79,27 +79,6 @@ class PetType < ApplicationRecord
species_human_name: possibly_new_species.human_name) species_human_name: possibly_new_species.human_name)
end end
def needed_items
# If I need this item on a pet type, that means that we've already seen it
# and it's body-specific. So, there's a body-specific asset for the item,
# but no asset that fits this pet type.
i = Item.arel_table
psa = ParentSwfAssetRelationship.arel_table
sa = SwfAsset.arel_table
Item.where('(' + ParentSwfAssetRelationship.select('count(DISTINCT body_id)').joins(:swf_asset).
where(
psa[:parent_id].eq(i[:id]).and(
psa[:parent_type].eq('Item').and(
sa[:body_id].not_eq(self.body_id)))
).to_sql + ') > 1').
where(ParentSwfAssetRelationship.joins(:swf_asset).where(
psa[:parent_id].eq(i[:id]).and(
psa[:parent_type].eq('Item').and(
sa[:body_id].in([self.body_id, 0])))
).exists.not)
end
def add_pet_state_from_biology!(biology) def add_pet_state_from_biology!(biology)
pet_state = PetState.from_pet_type_and_biology_info(self, biology) pet_state = PetState.from_pet_type_and_biology_info(self, biology)
pet_state pet_state

View file

@ -1,19 +0,0 @@
- title "Needed items for #{@pet_type.human_name}"
%h2
= image_tag "https://pets.neopets.com/cpn/#{@pet_name}/1/1.png",
:class => 'inline-image'
%span.pet-name= @pet_name
can model&hellip;
%ul.buttons
%li
= form_tag load_pet_path do
= origin_tag 'needed_items'
= hidden_field_tag 'name', @pet_name
= submit_tag "I'm wearing one now!", :class => 'loud'
%li
= link_to 'What do I own?', 'https://www.neopets.com/closet.phtml',
:class => 'button', :target => '_blank'
= render @items
- content_for :stylesheets do
= page_stylesheet_link_tag "layouts/items"

View file

@ -1,42 +1,20 @@
- title t('modeling_hub') - title t('modeling_hub')
= form_tag load_pet_path, :id => 'needed-items-form' do
- localized_cache :action_suffix => 'needed_items_content' do
%h3= t '.needed_items.header'
%p= t '.needed_items.explanation'
= origin_tag bulk_pets_path
= destination_tag 'needed_items'
%input#needed-items-pet-name-field{:type => "text", :name => "name"}/
%input{:type => "submit", :value => t('.needed_items.submit')}/
#needed-items-alert.alert
#needed-items-pet.script-only
%h4
%img#needed-items-pet-thumbnail.inline-image
%span#needed-items-pet-header
%button#needed-items-reload= t '.needed_items.reload'
%ul#needed-items-pet-items
= form_tag load_pet_path, :id => 'bulk-pets-form' do = form_tag load_pet_path, :id => 'bulk-pets-form' do
- localized_cache :action_suffix => 'bulk_pets_content' do - localized_cache :action_suffix => 'bulk_pets_content' do
%h3= t '.bulk_pets.header' %h3= t '.header'
%p= t '.bulk_pets.explanation' %p= t '.explanation'
= origin_tag bulk_pets_path = origin_tag bulk_pets_path
%div.noscript %div.noscript
%input{:name => "name", :type => "text"}/ %input{:name => "name", :type => "text"}/
%input{:type => "submit", :value => t('.bulk_pets.submit')}/ %input{:type => "submit", :value => t('.submit')}/
%div.script-only %div.script-only
%textarea %textarea
%button#bulk-pets-form-add{:type => "button"}= t '.bulk_pets.add' %button#bulk-pets-form-add{:type => "button"}= t '.add'
%button#bulk-pets-form-clear{:type => "button"}= t '.bulk_pets.clear' %button#bulk-pets-form-clear{:type => "button"}= t '.clear'
%ul %ul
- localized_cache :action_suffix => 'templates' do - localized_cache :action_suffix => 'templates' do
@ -70,12 +48,12 @@
%li.waiting %li.waiting
%img{:src => '${pet_thumbnail}'} %img{:src => '${pet_thumbnail}'}
%span.name ${pet_name} %span.name ${pet_name}
%span.waiting-message= t '.bulk_pets.waiting' %span.waiting-message= t '.waiting'
%span.loading-message= t '.bulk_pets.loading' %span.loading-message= t '.loading'
%span.response %span.response
%script#bulk-pets-submission-success-template{:type => 'text/x-jquery/tmpl'} %script#bulk-pets-submission-success-template{:type => 'text/x-jquery/tmpl'}
= t '.bulk_pets.submission_success', :points => '${points}' = t '.submission_success', :points => '${points}'
- content_for :javascripts do - content_for :javascripts do
= include_javascript_libraries :jquery, :jquery_tmpl = include_javascript_libraries :jquery, :jquery_tmpl

View file

@ -630,27 +630,17 @@ en-MEEP:
pets: pets:
bulk: bulk:
needed_items: header: Meep pets in bulk
header: Looking for ways to contreepute? explanation:
explanation: Got a lot of pets to meep? Just keep meeping them into the box below,
Meep your pet's name below and we'll tell you what items you can or even meep in a whole list of names, one name per line. Thanks for
meep. Thanks for your meep! your meep!
submit: Meep submit: Meep pet
pet_header: Items %{pet_name} can meep add: Meep
reload: Remeep clear: Cleer
item_owned: You own this meepit waiting: Weeting…
bulk_pets: loading: Leeding…
header: Meep pets in bulk submission_success: "%{points} peeps"
explanation:
Got a lot of pets to meep? Just keep meeping them into the box below,
or even meep in a whole list of names, one name per line. Thanks for
your meep!
submit: Meep pet
add: Meep
clear: Cleer
waiting: Weeting…
loading: Leeding…
submission_success: "%{points} peeps"
load: load:
not_found: We couldn't meep a pet by that name. Is it meeped correctly? not_found: We couldn't meep a pet by that name. Is it meeped correctly?

View file

@ -751,28 +751,18 @@ en:
pets: pets:
bulk: bulk:
needed_items: header: Model pets in bulk
header: Looking for ways to contribute? explanation:
explanation: Got a lot of pets to model? Just keep typing them into the box below,
Enter your pet's name below and we'll tell you what items you can or even paste in a whole list of names, one name per line. We'll
model. Thanks for your help! stagger them over time to keep our servers happy. Thanks for your
submit: Submit help!
pet_header: Items %{pet_name} can model submit: Load pet
reload: Reload add: Add
item_owned: You own this item clear: Clear
bulk_pets: waiting: Waiting…
header: Model pets in bulk loading: Loading…
explanation: submission_success: "%{points} points"
Got a lot of pets to model? Just keep typing them into the box below,
or even paste in a whole list of names, one name per line. We'll
stagger them over time to keep our servers happy. Thanks for your
help!
submit: Load pet
add: Add
clear: Clear
waiting: Waiting…
loading: Loading…
submission_success: "%{points} points"
load: load:
not_found: We couldn't find a pet by that name. Is it spelled correctly? not_found: We couldn't find a pet by that name. Is it spelled correctly?

View file

@ -498,24 +498,16 @@ es:
default_human_name: (una especie nueva) default_human_name: (una especie nueva)
pets: pets:
bulk: bulk:
needed_items: header: Hacer que desfilen varios pets a la vez
header: ¿Quieres contribuir en la página? explanation: "¿Tienes muchos pets para que desfilen?
explanation: ¡Escribe el nombre de tu pet aquí abajo y te diremos qué objetos nos hace falta junto a esa especie de pet para actualizar la base de datos! ¡Gracias por tu ayuda!
submit: Enviar
pet_header: Objetos que tu pet %{pet_name} puede posar
reload: Actualizar
item_owned: Tú tienes este objeto
bulk_pets:
header: Hacer que desfilen varios pets a la vez
explanation: "¿Tienes muchos pets para que desfilen?
Escribe o pega una lista de pets, recuerda añadir un nombre por línea :P ¡Muchas gracias por tu ayuda!" Escribe o pega una lista de pets, recuerda añadir un nombre por línea :P ¡Muchas gracias por tu ayuda!"
submit: Cargar pet submit: Cargar pet
add: Añadir add: Añadir
clear: Limpiar clear: Limpiar
waiting: Esperando… waiting: Esperando…
loading: Cargando… loading: Cargando…
submission_success: "%{points} puntos" submission_success: "%{points} puntos"
load: load:
not_found: No hemos podido encontrar a un pet con ese nombre. ¿Lo has escrito correctamente? not_found: No hemos podido encontrar a un pet con ese nombre. ¿Lo has escrito correctamente?
asset_download_error: Hemos encontrado el pet que intentas vestir, pero no hemos podido descargar las imágenes que lo asocian. Posiblemente Neopets está caído. ¡Por favor inténtalo de nuevo más tarde! asset_download_error: Hemos encontrado el pet que intentas vestir, pero no hemos podido descargar las imágenes que lo asocian. Posiblemente Neopets está caído. ¡Por favor inténtalo de nuevo más tarde!

View file

@ -494,22 +494,14 @@ pt:
default_human_name: (uma nova espécie) default_human_name: (uma nova espécie)
pets: pets:
bulk: bulk:
needed_items: header: Modele pets em massa
header: Procurando maneiras de ajudar? explanation: Tem um monte de pets para modelar? Basta digitar seus nomes na caixa abaixo, ou até mesmo colar toda uma lista de nomes, um nome por linha. Obrigado por sua ajuda!
explanation: Digite o nome do seu pet e nós diremos quais itens você pode modelar. Obrigado pela ajuda submit: Carregar pet
submit: Enviar add: Adicionar
pet_header: Itens que %{pet_name} pode modelar clear: Limpar
reload: Recarregar waiting: Esperando…
item_owned: Você possui este item loading: Carregando…
bulk_pets: submission_success: "%{points} pontos"
header: Modele pets em massa
explanation: Tem um monte de pets para modelar? Basta digitar seus nomes na caixa abaixo, ou até mesmo colar toda uma lista de nomes, um nome por linha. Obrigado por sua ajuda!
submit: Carregar pet
add: Adicionar
clear: Limpar
waiting: Esperando…
loading: Carregando…
submission_success: "%{points} pontos"
load: load:
not_found: Não foi possível achar um pet com esse nome. Está escrito corretamente? not_found: Não foi possível achar um pet com esse nome. Está escrito corretamente?
asset_download_error: Nós achamos o pet e o que ele está vestindo, mas não foi possível baixar os dados. Talvez Neopets esteja fora do ar. Por favor tente mais tarde! asset_download_error: Nós achamos o pet e o que ele está vestindo, mas não foi possível baixar os dados. Talvez Neopets esteja fora do ar. Por favor tente mais tarde!

View file

@ -26,7 +26,6 @@ OpenneoImpressItems::Application.routes.draw do
resources :appearances, controller: 'item_appearances', only: [:index] resources :appearances, controller: 'item_appearances', only: [:index]
collection do collection do
get :needed
get "sources/:ids", action: :sources get "sources/:ids", action: :sources
end end
end end
@ -102,4 +101,4 @@ OpenneoImpressItems::Application.routes.draw do
get '/sitemap.xml' => 'sitemap#index', :as => :sitemap, :format => :xml get '/sitemap.xml' => 'sitemap#index', :as => :sitemap, :format => :xml
get '/robots.txt' => 'sitemap#robots', :as => :robots, :format => :text get '/robots.txt' => 'sitemap#robots', :as => :robots, :format => :text
post '/locales/choose' => 'locales#choose', :as => :choose_locale post '/locales/choose' => 'locales#choose', :as => :choose_locale
end end