diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 0b315f8e..2ee9d51c 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -72,7 +72,7 @@ class ItemsController < ApplicationController includes_child_translations.group_by(&:species) trading_closet_hangers = @item.closet_hangers.trading.newest. - includes(:user) + user_is_active.includes(:user) @trading_closet_hangers_by_owned = { true => trading_closet_hangers.filter { |c| c.owned? }, diff --git a/app/models/closet_hanger.rb b/app/models/closet_hanger.rb index 6b15ddc6..d80b5f70 100644 --- a/app/models/closet_hanger.rb +++ b/app/models/closet_hanger.rb @@ -46,6 +46,10 @@ class ClosetHanger < ApplicationRecord scope :newest, -> { order(arel_table[:created_at].desc) } scope :owned_before_wanted, -> { order(arel_table[:owned].desc) } scope :unlisted, -> { where(:list_id => nil) } + scope :user_is_active, -> { + u = User.arel_table + joins(:user).where(u[:last_trade_activity_at].gteq(6.months.ago)) + } before_validation :merge_quantities, :set_owned_by_list