diff --git a/app/models/item.rb b/app/models/item.rb index 333f016c..fd7e7d01 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -65,6 +65,16 @@ class Item < ActiveRecord::Base condition = i[:rarity_index].in(Item::NCRarities).or(i[:is_manually_nc]) where(condition.not) } + scope :is_pb, -> { + Item.joins(:translations).where('locale = ?', 'en'). + where('description LIKE ?', + '%' + Item.sanitize_sql_like(PAINTBRUSH_SET_DESCRIPTION) + '%') + } + scope :is_not_pb, -> { + Item.joins(:translations).where('locale = ?', 'en'). + where('description NOT LIKE ?', + '%' + Item.sanitize_sql_like(PAINTBRUSH_SET_DESCRIPTION) + '%') + } def closeted? @owned || @wanted diff --git a/app/models/item/search/query.rb b/app/models/item/search/query.rb index bc77a838..6bb41f64 100644 --- a/app/models/item/search/query.rb +++ b/app/models/item/search/query.rb @@ -44,6 +44,8 @@ class Item filters << (is_positive ? Filter.is_nc : Filter.is_not_nc) when 'np' filters << (is_positive ? Filter.is_np : Filter.is_not_np) + when 'pb' + filters << (is_positive ? Filter.is_pb : Filter.is_not_pb) else message = I18n.translate('items.search.errors.not_found.label', :label => "is:#{value}") @@ -114,6 +116,14 @@ class Item def self.is_not_np self.new Item.is_nc, '-is:np' end + + def self.is_pb + self.new Item.is_pb, 'is:pb' + end + + def self.is_not_pb + self.new Item.is_not_pb, '-is:pb' + end end end end