Compare commits

..

2 commits

Author SHA1 Message Date
05c8e7f618 Oops, include default-list hangers in the trade lists
Without the `left_outer_joins`, this query only returns hangers that
have a matching list, which defeats the purpose of two of the three
clauses! lol
2024-01-19 01:27:57 -08:00
ebb1be88a1 Lil shout-out for the new active-users list filtering
Just a little message that's even timebomb-scheduled to disappear!
2024-01-19 01:18:24 -08:00
2 changed files with 22 additions and 19 deletions

View file

@ -19,29 +19,27 @@ class ClosetHanger < ApplicationRecord
} }
scope :trading, -> { scope :trading, -> {
ch = arel_table ch = arel_table
# sigh… our default-lists continue to be a pain
cl = ClosetList.arel_table cl = ClosetList.arel_table
u = User.arel_table u = User.arel_table
joins(:user, :list).where( joins(:user).left_outer_joins(:list).where(
# sigh… our default-lists continue to be a pain
(
ch[:list_id].not_eq(nil).and(cl[:visibility].gteq( ch[:list_id].not_eq(nil).and(cl[:visibility].gteq(
ClosetVisibility[:trading].id)) ClosetVisibility[:trading].id))
).or( ).or(where(
( (
ch[:list_id].eq(nil).and(ch[:owned].eq(true)) ch[:list_id].eq(nil).and(ch[:owned].eq(true))
).and( ).and(
u[:owned_closet_hangers_visibility].gteq( u[:owned_closet_hangers_visibility].gteq(
ClosetVisibility[:trading].id) ClosetVisibility[:trading].id)
) )
).or( )).or(where(
( (
ch[:list_id].eq(nil).and(ch[:owned].eq(false)) ch[:list_id].eq(nil).and(ch[:owned].eq(false))
).and( ).and(
u[:wanted_closet_hangers_visibility].gteq( u[:wanted_closet_hangers_visibility].gteq(
ClosetVisibility[:trading].id) ClosetVisibility[:trading].id)
) )
) ))
)
} }
scope :newest, -> { order(arel_table[:created_at].desc) } scope :newest, -> { order(arel_table[:created_at].desc) }
scope :owned_before_wanted, -> { order(arel_table[:owned].desc) } scope :owned_before_wanted, -> { order(arel_table[:owned].desc) }

View file

@ -35,6 +35,11 @@
= list_zones @restricted_zones = list_zones @restricted_zones
#trade-hangers #trade-hangers
- if Time.now < Date.new(2024, 1, 26)
%p
✨⏳️
%i We now only show recently-updated lists here!
⏳️✨
- [true, false].each do |owned| - [true, false].each do |owned|
%p %p
%strong %strong