From d12b21896c1ccf58228b248fd88c73610800ba6d Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 26 Jul 2023 11:51:52 -0700 Subject: [PATCH] Add is:pb back to item search --- app/models/item.rb | 10 ++++++++++ app/models/item/search/query.rb | 10 ++++++++++ 2 files changed, 20 insertions(+) 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