forked from OpenNeo/impress
Remove duplicates from the list of trades
Oh yeah, a long-standing limitation. Good thing we're better at stuff now! This is also probably the real cause of the weird number of slight discrepancies between main DTI and DTI 2020 when I eyeballed stuff lol oh, well, that and the missing default-lists. A bit messy!
This commit is contained in:
parent
05c8e7f618
commit
f008dff3f4
7 changed files with 22 additions and 18 deletions
|
@ -71,12 +71,16 @@ class ItemsController < ApplicationController
|
||||||
@basic_colored_pet_types_by_species_id = PetType.special_color_or_basic(@item.special_color).
|
@basic_colored_pet_types_by_species_id = PetType.special_color_or_basic(@item.special_color).
|
||||||
includes_child_translations.group_by(&:species)
|
includes_child_translations.group_by(&:species)
|
||||||
|
|
||||||
trading_closet_hangers = @item.closet_hangers.trading.newest.
|
trading_closet_hangers = @item.closet_hangers.trading.includes(:user).
|
||||||
user_is_active.includes(:user)
|
user_is_active.order('users.last_trade_activity_at DESC')
|
||||||
|
|
||||||
@trading_closet_hangers_by_owned = {
|
|
||||||
true => trading_closet_hangers.filter { |c| c.owned? },
|
owned_trading_hangers = trading_closet_hangers.filter { |c| c.owned? }
|
||||||
false => trading_closet_hangers.filter { |c| c.wanted? },
|
wanted_trading_hangers = trading_closet_hangers.filter { |c| c.wanted? }
|
||||||
|
|
||||||
|
@trading_users_by_owned = {
|
||||||
|
true => owned_trading_hangers.map(&:user).uniq,
|
||||||
|
false => wanted_trading_hangers.map(&:user).uniq,
|
||||||
}
|
}
|
||||||
|
|
||||||
if user_signed_in?
|
if user_signed_in?
|
||||||
|
|
|
@ -83,14 +83,14 @@ module ItemsHelper
|
||||||
"https://www.neopets.com/genie.phtml?type=process_genie&criteria=exact&auctiongenie=#{CGI::escape item.name}"
|
"https://www.neopets.com/genie.phtml?type=process_genie&criteria=exact&auctiongenie=#{CGI::escape item.name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def trading_closet_hangers_header(owned, count)
|
def trading_users_header(owned, count)
|
||||||
ownership_key = owned ? 'owned' : 'wanted'
|
ownership_key = owned ? 'owned' : 'wanted'
|
||||||
translate ".trading_closet_hangers.header.#{ownership_key}", :count => count
|
translate ".trading_users.header.#{ownership_key}", :count => count
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_trading_closet_hangers(owned)
|
def render_trading_users(owned)
|
||||||
@trading_closet_hangers_by_owned[owned].map do |hanger|
|
@trading_users_by_owned[owned].map do |user|
|
||||||
link_to hanger.user.name, user_closet_hangers_path(hanger.user)
|
link_to user.name, user_closet_hangers_path(user)
|
||||||
end.to_sentence.html_safe
|
end.to_sentence.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -43,11 +43,11 @@
|
||||||
- [true, false].each do |owned|
|
- [true, false].each do |owned|
|
||||||
%p
|
%p
|
||||||
%strong
|
%strong
|
||||||
= trading_closet_hangers_header(owned, @trading_closet_hangers_by_owned[owned].size)
|
= trading_users_header(owned, @trading_users_by_owned[owned].size)
|
||||||
= render_trading_closet_hangers(owned)
|
= render_trading_users(owned)
|
||||||
%span.toggle
|
%span.toggle
|
||||||
%span.more= t '.trading_closet_hangers.show_more'
|
%span.more= t '.trading_users.show_more'
|
||||||
%span.less= t '.trading_closet_hangers.show_less'
|
%span.less= t '.trading_users.show_less'
|
||||||
|
|
||||||
- if user_signed_in?
|
- if user_signed_in?
|
||||||
#your-items-form
|
#your-items-form
|
||||||
|
|
|
@ -285,7 +285,7 @@ en-MEEP:
|
||||||
occupied_header: Occupeeps
|
occupied_header: Occupeeps
|
||||||
restricted_header: Restreeps
|
restricted_header: Restreeps
|
||||||
none: Meepless
|
none: Meepless
|
||||||
trading_closet_hangers:
|
trading_users:
|
||||||
header:
|
header:
|
||||||
owned:
|
owned:
|
||||||
zero: We don't know anymeep who has this item meep for trade.
|
zero: We don't know anymeep who has this item meep for trade.
|
||||||
|
|
|
@ -314,7 +314,7 @@ en:
|
||||||
occupied_header: Occupies
|
occupied_header: Occupies
|
||||||
restricted_header: Restricts
|
restricted_header: Restricts
|
||||||
none: None
|
none: None
|
||||||
trading_closet_hangers:
|
trading_users:
|
||||||
header:
|
header:
|
||||||
owned:
|
owned:
|
||||||
zero: We don't know anyone who has this item up for trade.
|
zero: We don't know anyone who has this item up for trade.
|
||||||
|
|
|
@ -224,7 +224,7 @@ es:
|
||||||
occupied_header: Ocupa
|
occupied_header: Ocupa
|
||||||
restricted_header: Restringe
|
restricted_header: Restringe
|
||||||
none: Nada
|
none: Nada
|
||||||
trading_closet_hangers:
|
trading_users:
|
||||||
header:
|
header:
|
||||||
owned:
|
owned:
|
||||||
zero: No conocemos a nadie que tenga este objeto para intercambiar.
|
zero: No conocemos a nadie que tenga este objeto para intercambiar.
|
||||||
|
|
|
@ -224,7 +224,7 @@ pt:
|
||||||
occupied_header: Ocupações
|
occupied_header: Ocupações
|
||||||
restricted_header: Restrições
|
restricted_header: Restrições
|
||||||
none: Nada
|
none: Nada
|
||||||
trading_closet_hangers:
|
trading_users:
|
||||||
header:
|
header:
|
||||||
owned:
|
owned:
|
||||||
zero: Ninguém quer trocar esse item
|
zero: Ninguém quer trocar esse item
|
||||||
|
|
Loading…
Reference in a new issue