1
0
Fork 0
forked from OpenNeo/impress

Update search filters to consider NP and PB mutually exclusive

`is:np` now means "is not NC and is not PB".

Note that it might be good to make NC and PB explicitly mutually
exclusive too? It would complicate queries though, and not matter in
most cases… the Burlap Usul Bow is the only item that we currently
return for `is:pb is:nc`, which is probably because of a rarity issue?
This commit is contained in:
Emi Matchu 2024-02-25 12:57:04 -08:00
parent a3dcaa0f0e
commit 52e81557c2
2 changed files with 13 additions and 3 deletions

View file

@ -39,10 +39,16 @@ class Item < ApplicationRecord
i = Item.arel_table
where(i[:rarity_index].in(Item::NCRarities).or(i[:is_manually_nc].eq(true)))
}
scope :is_np, -> {
scope :is_not_nc, -> {
i = Item.arel_table
where(i[:rarity_index].in(Item::NCRarities).or(i[:is_manually_nc].eq(true)).not)
}
scope :is_np, -> {
self.is_not_nc.is_not_pb
}
scope :is_not_np, -> {
self.merge Item.is_nc.or(Item.is_pb)
}
scope :is_pb, -> {
where('description LIKE ?',
'%' + sanitize_sql_like(PAINTBRUSH_SET_DESCRIPTION) + '%')

View file

@ -120,6 +120,10 @@ class Item
Filter.name_excludes(value, locale))
when 'is_nc'
filters << (is_positive ? Filter.is_nc : Filter.is_not_nc)
when 'is_pb'
filters << (is_positive ? Filter.is_pb : Filter.is_not_pb)
when 'is_np'
filters << (is_positive ? Filter.is_np : Filter.is_not_np)
when 'occupied_zone_set_name'
filters << (is_positive ?
Filter.occupies(value, locale) :
@ -255,7 +259,7 @@ class Item
end
def self.is_not_nc
self.new Item.is_np, '-is:nc'
self.new Item.is_not_nc, '-is:nc'
end
def self.is_np
@ -263,7 +267,7 @@ class Item
end
def self.is_not_np
self.new Item.is_nc, '-is:np'
self.new Item.is_not_np, '-is:np'
end
def self.is_pb