bug fix: pet importer no longer chokes when two pets wear the same item

This commit is contained in:
Emi Matchu 2012-10-01 13:22:17 -05:00
parent 2016216d42
commit 9fcc1b244a
2 changed files with 50 additions and 46 deletions

View file

@ -23,15 +23,19 @@ class NeopetsUser
pets = pets.map { |pet| Pet.find_or_initialize_by_name(pet.name) }
items = pets.each(&:load!).map(&:items).flatten
item_ids = items.map(&:id)
existing_hanger_item_ids = @app_user.closet_hangers.select(:item_id).where(:item_id => item_ids).map(&:item_id)
item_quantities = {}
items.each do |i|
item_quantities[i] ||= 0
item_quantities[i] += 1
end
@hangers = []
items.each do |item|
item_quantities.each do |item, quantity|
next if existing_hanger_item_ids.include?(item.id)
hanger = @app_user.closet_hangers.build
hanger.item = item
hanger.quantity = 1
hanger.quantity = quantity
@hangers << hanger
end
end

View file

@ -120,7 +120,7 @@ a.button, input[type=submit], button {
/* http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html */
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background: #006400 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #006400 url('/images/alert-overlay.png?1344550430') repeat-x;
border: 0;
display: inline-block;
padding: 0.5em 0.75em 0.45em;
@ -148,7 +148,7 @@ a.button:active, input[type=submit]:active, button:active {
}
/* line 93, ../../../app/stylesheets/_layout.sass */
a.button.loud, input[type=submit].loud, button.loud {
background: #ff5c00 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #ff5c00 url('/images/alert-overlay.png?1344550430') repeat-x;
font-size: 125%;
padding: 8px 14px 9px;
}
@ -611,7 +611,7 @@ body.closet_hangers-index #import-link {
/* http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html */
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background: #006400 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #006400 url('/images/alert-overlay.png?1344550430') repeat-x;
border: 0;
display: inline-block;
padding: 0.5em 0.75em 0.45em;
@ -624,7 +624,7 @@ body.closet_hangers-index #import-link {
position: relative;
font-weight: bold;
line-height: 1;
background: #ff5c00 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #ff5c00 url('/images/alert-overlay.png?1344550430') repeat-x;
}
/* line 34, ../../../app/stylesheets/partials/clean/_mixins.sass */
body.closet_hangers-index #import-link:hover {
@ -664,7 +664,7 @@ body.closet_hangers-index #closet-hangers-contact {
/* line 33, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers-contact a, body.closet_hangers-index #closet-hangers-contact > span {
text-decoration: none;
background-image: url('/images/neomail.png?1315327995');
background-image: url('/images/neomail.png?1344550430');
background-position: left center;
background-repeat: no-repeat;
color: inherit;
@ -678,7 +678,7 @@ body.closet_hangers-index #closet-hangers-contact a:hover, body.closet_hangers-i
}
/* line 44, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers-contact > span {
background-image: url('/images/neomail_edit.png?1315327995');
background-image: url('/images/neomail_edit.png?1344550430');
}
/* line 47, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers-contact input[type=text], body.closet_hangers-index #closet-hangers-contact body.pets-bulk #bulk-pets-form textarea, body.pets-bulk #bulk-pets-form body.closet_hangers-index #closet-hangers-contact textarea {
@ -731,7 +731,7 @@ body.closet_hangers-index #toggle-help, body.closet_hangers-index #toggle-compar
/* http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html */
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background: #006400 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #006400 url('/images/alert-overlay.png?1344550430') repeat-x;
border: 0;
display: inline-block;
padding: 0.5em 0.75em 0.45em;
@ -775,7 +775,7 @@ body.closet_hangers-index #closet-hangers-extras a {
/* http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html */
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background: #006400 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #006400 url('/images/alert-overlay.png?1344550430') repeat-x;
border: 0;
display: inline-block;
padding: 0.5em 0.75em 0.45em;
@ -871,7 +871,7 @@ body.closet_hangers-index .closet-hangers-group > header .add-closet-list {
/* http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html */
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background: #006400 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #006400 url('/images/alert-overlay.png?1344550430') repeat-x;
border: 0;
display: inline-block;
padding: 0.5em 0.75em 0.45em;
@ -950,7 +950,7 @@ body.closet_hangers-index .closet-list .visibility-form input[type=submit] {
/* http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html */
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background: #006400 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #006400 url('/images/alert-overlay.png?1344550430') repeat-x;
border: 0;
display: inline-block;
padding: 0.5em 0.75em 0.45em;
@ -963,7 +963,7 @@ body.closet_hangers-index .closet-list .visibility-form input[type=submit] {
position: relative;
font-weight: bold;
line-height: 1;
background: #aaaaaa url('/images/alert-overlay.png?1315327995') repeat-x;
background: #aaaaaa url('/images/alert-overlay.png?1344550430') repeat-x;
-moz-opacity: 0.9;
-webkit-opacity: 0.9;
-o-opacity: 0.9;
@ -1041,7 +1041,7 @@ body.closet_hangers-index .closet-list .closet-list-controls a, body.closet_hang
/* http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html */
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background: #006400 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #006400 url('/images/alert-overlay.png?1344550430') repeat-x;
border: 0;
display: inline-block;
padding: 0.5em 0.75em 0.45em;
@ -1054,7 +1054,7 @@ body.closet_hangers-index .closet-list .closet-list-controls a, body.closet_hang
position: relative;
font-weight: bold;
line-height: 1;
background: #aaaaaa url('/images/alert-overlay.png?1315327995') repeat-x;
background: #aaaaaa url('/images/alert-overlay.png?1344550430') repeat-x;
-moz-opacity: 0.9;
-webkit-opacity: 0.9;
-o-opacity: 0.9;
@ -1177,7 +1177,7 @@ body.closet_hangers-index.current-user #closet-hangers .object:hover .closet-han
/* http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html */
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background: #006400 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #006400 url('/images/alert-overlay.png?1344550430') repeat-x;
border: 0;
display: inline-block;
padding: 0.5em 0.75em 0.45em;
@ -1190,7 +1190,7 @@ body.closet_hangers-index.current-user #closet-hangers .object:hover .closet-han
position: relative;
font-weight: bold;
line-height: 1;
background: #aaaaaa url('/images/alert-overlay.png?1315327995') repeat-x;
background: #aaaaaa url('/images/alert-overlay.png?1344550430') repeat-x;
-moz-opacity: 0.9;
-webkit-opacity: 0.9;
-o-opacity: 0.9;
@ -1485,7 +1485,7 @@ body.neopets_pages-new #back-to-items, body.neopets_pages-create #back-to-items
-ms-border-radius: 5px;
-khtml-border-radius: 5px;
border-radius: 5px;
background: #006400 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #006400 url('/images/alert-overlay.png?1344550430') repeat-x;
border: 0;
display: inline-block;
padding: 0.5em 0.75em 0.45em;
@ -1673,7 +1673,7 @@ body.items .campaign-progress-wrapper {
}
/* line 13, ../../../app/stylesheets/partials/_campaign-progress.sass */
body.items .campaign-progress-wrapper .button {
background: #ff5c00 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #ff5c00 url('/images/alert-overlay.png?1344550430') repeat-x;
font-size: 75%;
margin-left: 1em;
padding: 0.25em 0.75em;
@ -2071,7 +2071,7 @@ body.outfits-edit #pet-state-form label {
-ms-border-radius: 5px;
-khtml-border-radius: 5px;
border-radius: 5px;
background: #006400 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #006400 url('/images/alert-overlay.png?1344550430') repeat-x;
border: 0;
display: inline-block;
padding: 0.5em 0.75em 0.45em;
@ -2100,7 +2100,7 @@ body.outfits-edit #pet-state-form label:active {
}
/* line 67, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit #pet-state-form li.selected button {
background: #0b61a4 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #0b61a4 url('/images/alert-overlay.png?1344550430') repeat-x;
}
/* line 34, ../../../app/stylesheets/partials/clean/_mixins.sass */
body.outfits-edit #pet-state-form li.selected button:hover {
@ -2124,14 +2124,14 @@ body.outfits-edit #save-outfit-wrapper #share-outfit {
}
/* line 77, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit #save-outfit-wrapper.loading {
background-image: url('/images/loading.gif?1315327995');
background-image: url('/images/loading.gif?1344550430');
background-position: left center;
background-repeat: no-repeat;
padding-left: 20px;
}
/* line 83, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit #save-outfit, body.outfits-edit #save-outfit-not-signed-in, body.outfits-edit #save-current-outfit, body.outfits-edit #save-outfit-finish {
background: #ff5c00 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #ff5c00 url('/images/alert-overlay.png?1344550430') repeat-x;
}
/* line 34, ../../../app/stylesheets/partials/clean/_mixins.sass */
body.outfits-edit #save-outfit:hover, body.outfits-edit #save-outfit-not-signed-in:hover, body.outfits-edit #save-current-outfit:hover, body.outfits-edit #save-outfit-finish:hover {
@ -2601,7 +2601,7 @@ body.outfits-edit .object ul li a {
-ms-border-radius: 5px;
-khtml-border-radius: 5px;
border-radius: 5px;
background: #006400 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #006400 url('/images/alert-overlay.png?1344550430') repeat-x;
border: 0;
display: inline-block;
padding: 0.5em 0.75em 0.45em;
@ -2614,7 +2614,7 @@ body.outfits-edit .object ul li a {
position: relative;
font-weight: bold;
line-height: 1;
background: #aaaaaa url('/images/alert-overlay.png?1315327995') repeat-x;
background: #aaaaaa url('/images/alert-overlay.png?1344550430') repeat-x;
-moz-opacity: 0.9;
-webkit-opacity: 0.9;
-o-opacity: 0.9;
@ -2643,7 +2643,7 @@ body.outfits-edit .object:hover ul, body.outfits-edit .object:hover .object-info
}
/* line 361, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit .nc-icon {
background: url('/images/nc.png?1315327995') no-repeat;
background: url('/images/nc.png?1344550430') no-repeat;
height: 16px;
position: absolute;
right: 16px;
@ -2704,7 +2704,7 @@ body.outfits-edit #preview-outfits > ul {
list-style: none;
margin-left: 24px;
margin-right: 24px;
background: url('/images/loading.gif?1315327995') no-repeat center top;
background: url('/images/loading.gif?1344550430') no-repeat center top;
display: none;
font-family: "Droid Sans", Helvetica, Arial, Verdana, sans-serif;
margin: 0 auto 1em;
@ -2732,7 +2732,7 @@ body.outfits-edit #preview-outfits > ul > li .outfit-star {
height: 16px;
position: relative;
width: 16px;
background-image: url('/images/unstarred.png?1315327995');
background-image: url('/images/unstarred.png?1344550430');
background-position: left top;
background-repeat: no-repeat;
cursor: pointer;
@ -2742,11 +2742,11 @@ body.outfits-edit #preview-outfits > ul > li .outfit-star {
}
/* line 14, ../../../app/stylesheets/outfits/_star.sass */
body.outfits-edit #preview-outfits > ul > li.starred .outfit-star {
background-image: url('/images/star.png?1315327995');
background-image: url('/images/star.png?1344550430');
}
/* line 16, ../../../app/stylesheets/outfits/_star.sass */
body.outfits-edit #preview-outfits > ul > li.loading .outfit-star {
background-image: url('/images/loading.gif?1315327995');
background-image: url('/images/loading.gif?1344550430');
}
/* line 7, ../../../app/stylesheets/partials/_outfit.sass */
body.outfits-edit #preview-outfits > ul > li header, body.outfits-edit #preview-outfits > ul > li footer {
@ -2929,7 +2929,7 @@ body.outfits-edit #preview-outfits > ul > li.thumbnail-available .outfit-thumbna
}
/* line 531, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit #preview-outfits > ul > li.loading .outfit-star {
background-image: url('/images/loading_outfit_pane.gif?1343748088');
background-image: url('/images/loading_outfit_pane.gif?1344550430');
}
/* line 534, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit #preview-outfits #preview-outfits-not-logged-in {
@ -2968,7 +2968,7 @@ body.outfits-edit #preview-outfits #preview-outfits-not-logged-in #preview-outfi
-ms-border-radius: 5px;
-khtml-border-radius: 5px;
border-radius: 5px;
background: #006400 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #006400 url('/images/alert-overlay.png?1344550430') repeat-x;
border: 0;
display: inline-block;
padding: 0.5em 0.75em 0.45em;
@ -2981,7 +2981,7 @@ body.outfits-edit #preview-outfits #preview-outfits-not-logged-in #preview-outfi
position: relative;
font-weight: bold;
line-height: 1;
background: #ff5c00 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #ff5c00 url('/images/alert-overlay.png?1344550430') repeat-x;
}
/* line 34, ../../../app/stylesheets/partials/clean/_mixins.sass */
body.outfits-edit #preview-outfits #preview-outfits-not-logged-in #preview-outfits-log-in:hover {
@ -3314,7 +3314,7 @@ body.outfits-edit form#save-outfit-form .outfit-star {
height: 16px;
position: relative;
width: 16px;
background-image: url('/images/unstarred.png?1315327995');
background-image: url('/images/unstarred.png?1344550430');
background-position: left top;
background-repeat: no-repeat;
cursor: pointer;
@ -3324,11 +3324,11 @@ body.outfits-edit form#save-outfit-form .outfit-star {
}
/* line 14, ../../../app/stylesheets/outfits/_star.sass */
body.outfits-edit form#save-outfit-form.starred .outfit-star {
background-image: url('/images/star.png?1315327995');
background-image: url('/images/star.png?1344550430');
}
/* line 16, ../../../app/stylesheets/outfits/_star.sass */
body.outfits-edit form#save-outfit-form.loading .outfit-star {
background-image: url('/images/loading.gif?1315327995');
background-image: url('/images/loading.gif?1344550430');
}
/* line 22, ../../../app/stylesheets/outfits/_star.sass */
body.outfits-edit form#save-outfit-form .outfit-star {
@ -3447,7 +3447,7 @@ body.outfits-index #outfits > li .outfit-star {
height: 16px;
position: relative;
width: 16px;
background-image: url('/images/unstarred.png?1315327995');
background-image: url('/images/unstarred.png?1344550430');
background-position: left top;
background-repeat: no-repeat;
cursor: pointer;
@ -3457,11 +3457,11 @@ body.outfits-index #outfits > li .outfit-star {
}
/* line 14, ../../../app/stylesheets/outfits/_star.sass */
body.outfits-index #outfits > li.starred .outfit-star {
background-image: url('/images/star.png?1315327995');
background-image: url('/images/star.png?1344550430');
}
/* line 16, ../../../app/stylesheets/outfits/_star.sass */
body.outfits-index #outfits > li.loading .outfit-star {
background-image: url('/images/loading.gif?1315327995');
background-image: url('/images/loading.gif?1344550430');
}
/* line 7, ../../../app/stylesheets/partials/_outfit.sass */
body.outfits-index #outfits > li header, body.outfits-index #outfits > li footer {
@ -3583,7 +3583,7 @@ body.outfits-new .campaign-progress-wrapper {
}
/* line 13, ../../../app/stylesheets/partials/_campaign-progress.sass */
body.outfits-new .campaign-progress-wrapper .button {
background: #ff5c00 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #ff5c00 url('/images/alert-overlay.png?1344550430') repeat-x;
font-size: 75%;
margin-left: 1em;
padding: 0.25em 0.75em;
@ -3714,7 +3714,7 @@ body.outfits-new #load-pet-to-wardrobe input {
}
/* line 57, ../../../app/stylesheets/outfits/_new.sass */
body.outfits-new #load-pet-to-wardrobe button {
background: #ff5c00 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #ff5c00 url('/images/alert-overlay.png?1344550430') repeat-x;
font-size: 125%;
padding: 8px 14px 9px;
font-size: 67%;
@ -3963,7 +3963,7 @@ body.outfits-show .campaign-progress-wrapper {
}
/* line 13, ../../../app/stylesheets/partials/_campaign-progress.sass */
body.outfits-show .campaign-progress-wrapper .button {
background: #ff5c00 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #ff5c00 url('/images/alert-overlay.png?1344550430') repeat-x;
font-size: 75%;
margin-left: 1em;
padding: 0.25em 0.75em;
@ -4097,7 +4097,7 @@ body.pets-bulk #needed-items-form .object-owned {
}
/* line 43, ../../../app/stylesheets/pets/_bulk.sass */
body.pets-bulk #needed-items-form.loading-pet #needed-items-pet-name-field, body.pets-bulk #needed-items-form.loading-items #needed-items-pet-name-field {
background-image: url('/images/loading.gif?1315327995');
background-image: url('/images/loading.gif?1344550430');
background-position: center right;
background-repeat: no-repeat;
}
@ -4224,7 +4224,7 @@ body.static-donate .campaign-progress-wrapper {
}
/* line 13, ../../../app/stylesheets/partials/_campaign-progress.sass */
body.static-donate .campaign-progress-wrapper .button {
background: #ff5c00 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #ff5c00 url('/images/alert-overlay.png?1344550430') repeat-x;
font-size: 75%;
margin-left: 1em;
padding: 0.25em 0.75em;
@ -4380,7 +4380,7 @@ body.static-donate #image-mode-beta form input {
}
/* line 114, ../../../app/stylesheets/static/_donate.sass */
body.static-donate #image-mode-beta form button {
background: #ff5c00 url('/images/alert-overlay.png?1315327995') repeat-x;
background: #ff5c00 url('/images/alert-overlay.png?1344550430') repeat-x;
}
/* line 34, ../../../app/stylesheets/partials/clean/_mixins.sass */
body.static-donate #image-mode-beta form button:hover {