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:
parent
a3dcaa0f0e
commit
52e81557c2
2 changed files with 13 additions and 3 deletions
|
@ -39,10 +39,16 @@ class Item < ApplicationRecord
|
||||||
i = Item.arel_table
|
i = Item.arel_table
|
||||||
where(i[:rarity_index].in(Item::NCRarities).or(i[:is_manually_nc].eq(true)))
|
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
|
i = Item.arel_table
|
||||||
where(i[:rarity_index].in(Item::NCRarities).or(i[:is_manually_nc].eq(true)).not)
|
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, -> {
|
scope :is_pb, -> {
|
||||||
where('description LIKE ?',
|
where('description LIKE ?',
|
||||||
'%' + sanitize_sql_like(PAINTBRUSH_SET_DESCRIPTION) + '%')
|
'%' + sanitize_sql_like(PAINTBRUSH_SET_DESCRIPTION) + '%')
|
||||||
|
|
|
@ -120,6 +120,10 @@ class Item
|
||||||
Filter.name_excludes(value, locale))
|
Filter.name_excludes(value, locale))
|
||||||
when 'is_nc'
|
when 'is_nc'
|
||||||
filters << (is_positive ? Filter.is_nc : Filter.is_not_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'
|
when 'occupied_zone_set_name'
|
||||||
filters << (is_positive ?
|
filters << (is_positive ?
|
||||||
Filter.occupies(value, locale) :
|
Filter.occupies(value, locale) :
|
||||||
|
@ -255,7 +259,7 @@ class Item
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.is_not_nc
|
def self.is_not_nc
|
||||||
self.new Item.is_np, '-is:nc'
|
self.new Item.is_not_nc, '-is:nc'
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.is_np
|
def self.is_np
|
||||||
|
@ -263,7 +267,7 @@ class Item
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.is_not_np
|
def self.is_not_np
|
||||||
self.new Item.is_nc, '-is:np'
|
self.new Item.is_not_np, '-is:np'
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.is_pb
|
def self.is_pb
|
||||||
|
|
Loading…
Reference in a new issue