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).
|
||||
includes_child_translations.group_by(&:species)
|
||||
|
||||
trading_closet_hangers = @item.closet_hangers.trading.newest.
|
||||
user_is_active.includes(:user)
|
||||
trading_closet_hangers = @item.closet_hangers.trading.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? },
|
||||
false => trading_closet_hangers.filter { |c| c.wanted? },
|
||||
|
||||
owned_trading_hangers = trading_closet_hangers.filter { |c| c.owned? }
|
||||
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?
|
||||
|
|
|
@ -83,14 +83,14 @@ module ItemsHelper
|
|||
"https://www.neopets.com/genie.phtml?type=process_genie&criteria=exact&auctiongenie=#{CGI::escape item.name}"
|
||||
end
|
||||
|
||||
def trading_closet_hangers_header(owned, count)
|
||||
def trading_users_header(owned, count)
|
||||
ownership_key = owned ? 'owned' : 'wanted'
|
||||
translate ".trading_closet_hangers.header.#{ownership_key}", :count => count
|
||||
translate ".trading_users.header.#{ownership_key}", :count => count
|
||||
end
|
||||
|
||||
def render_trading_closet_hangers(owned)
|
||||
@trading_closet_hangers_by_owned[owned].map do |hanger|
|
||||
link_to hanger.user.name, user_closet_hangers_path(hanger.user)
|
||||
def render_trading_users(owned)
|
||||
@trading_users_by_owned[owned].map do |user|
|
||||
link_to user.name, user_closet_hangers_path(user)
|
||||
end.to_sentence.html_safe
|
||||
end
|
||||
|
||||
|
|
|
@ -43,11 +43,11 @@
|
|||
- [true, false].each do |owned|
|
||||
%p
|
||||
%strong
|
||||
= trading_closet_hangers_header(owned, @trading_closet_hangers_by_owned[owned].size)
|
||||
= render_trading_closet_hangers(owned)
|
||||
= trading_users_header(owned, @trading_users_by_owned[owned].size)
|
||||
= render_trading_users(owned)
|
||||
%span.toggle
|
||||
%span.more= t '.trading_closet_hangers.show_more'
|
||||
%span.less= t '.trading_closet_hangers.show_less'
|
||||
%span.more= t '.trading_users.show_more'
|
||||
%span.less= t '.trading_users.show_less'
|
||||
|
||||
- if user_signed_in?
|
||||
#your-items-form
|
||||
|
|
|
@ -285,7 +285,7 @@ en-MEEP:
|
|||
occupied_header: Occupeeps
|
||||
restricted_header: Restreeps
|
||||
none: Meepless
|
||||
trading_closet_hangers:
|
||||
trading_users:
|
||||
header:
|
||||
owned:
|
||||
zero: We don't know anymeep who has this item meep for trade.
|
||||
|
|
|
@ -314,7 +314,7 @@ en:
|
|||
occupied_header: Occupies
|
||||
restricted_header: Restricts
|
||||
none: None
|
||||
trading_closet_hangers:
|
||||
trading_users:
|
||||
header:
|
||||
owned:
|
||||
zero: We don't know anyone who has this item up for trade.
|
||||
|
|
|
@ -224,7 +224,7 @@ es:
|
|||
occupied_header: Ocupa
|
||||
restricted_header: Restringe
|
||||
none: Nada
|
||||
trading_closet_hangers:
|
||||
trading_users:
|
||||
header:
|
||||
owned:
|
||||
zero: No conocemos a nadie que tenga este objeto para intercambiar.
|
||||
|
|
|
@ -224,7 +224,7 @@ pt:
|
|||
occupied_header: Ocupações
|
||||
restricted_header: Restrições
|
||||
none: Nada
|
||||
trading_closet_hangers:
|
||||
trading_users:
|
||||
header:
|
||||
owned:
|
||||
zero: Ninguém quer trocar esse item
|
||||
|
|
Loading…
Reference in a new issue