forked from OpenNeo/impress
Oops, fix remaining references to locale in item search
This is both unnecessary now, but also caused a bug in the new search stuff where searching by zone would pass an extra `locale` argument to a filter that doesn't need it!
This commit is contained in:
parent
61a4dcad02
commit
e5bf6d6ba1
2 changed files with 14 additions and 20 deletions
|
@ -29,10 +29,10 @@ class Item < ApplicationRecord
|
||||||
|
|
||||||
scope :with_closet_hangers, -> { joins(:closet_hangers) }
|
scope :with_closet_hangers, -> { joins(:closet_hangers) }
|
||||||
|
|
||||||
scope :name_includes, ->(value, locale = I18n.locale) {
|
scope :name_includes, ->(value) {
|
||||||
Item.where("name LIKE ?", "%" + sanitize_sql_like(value) + "%")
|
Item.where("name LIKE ?", "%" + sanitize_sql_like(value) + "%")
|
||||||
}
|
}
|
||||||
scope :name_excludes, ->(value, locale = I18n.locale) {
|
scope :name_excludes, ->(value) {
|
||||||
Item.where("name NOT LIKE ?", "%" + sanitize_sql_like(value) + "%")
|
Item.where("name NOT LIKE ?", "%" + sanitize_sql_like(value) + "%")
|
||||||
}
|
}
|
||||||
scope :is_nc, -> {
|
scope :is_nc, -> {
|
||||||
|
|
|
@ -17,11 +17,6 @@ class Item
|
||||||
def to_s
|
def to_s
|
||||||
@text || @filters.map(&:to_s).join(' ')
|
@text || @filters.map(&:to_s).join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.locale
|
|
||||||
(I18n.fallbacks[I18n.locale] &
|
|
||||||
I18n.locales_with_neopets_language_code).first
|
|
||||||
end
|
|
||||||
|
|
||||||
TEXT_FILTER_EXPR = /([+-]?)(?:(\p{Word}+):)?(?:"([^"]+)"|(\S+))/
|
TEXT_FILTER_EXPR = /([+-]?)(?:(\p{Word}+):)?(?:"([^"]+)"|(\S+))/
|
||||||
def self.from_text(text, user=nil)
|
def self.from_text(text, user=nil)
|
||||||
|
@ -35,8 +30,8 @@ class Item
|
||||||
case key
|
case key
|
||||||
when 'name'
|
when 'name'
|
||||||
filters << (is_positive ?
|
filters << (is_positive ?
|
||||||
Filter.name_includes(value, locale) :
|
Filter.name_includes(value) :
|
||||||
Filter.name_excludes(value, locale))
|
Filter.name_excludes(value))
|
||||||
when 'occupies'
|
when 'occupies'
|
||||||
filters << (is_positive ?
|
filters << (is_positive ?
|
||||||
Filter.occupies(value) :
|
Filter.occupies(value) :
|
||||||
|
@ -117,8 +112,8 @@ class Item
|
||||||
case filter_params[:key]
|
case filter_params[:key]
|
||||||
when 'name'
|
when 'name'
|
||||||
filters << (is_positive ?
|
filters << (is_positive ?
|
||||||
Filter.name_includes(value, locale) :
|
Filter.name_includes(value) :
|
||||||
Filter.name_excludes(value, locale))
|
Filter.name_excludes(value))
|
||||||
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'
|
when 'is_pb'
|
||||||
|
@ -126,13 +121,12 @@ class Item
|
||||||
when 'is_np'
|
when 'is_np'
|
||||||
filters << (is_positive ? Filter.is_np : Filter.is_not_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) :
|
||||||
Filter.occupies(value, locale) :
|
Filter.not_occupies(value))
|
||||||
Filter.not_occupies(value, locale))
|
|
||||||
when 'restricted_zone_set_name'
|
when 'restricted_zone_set_name'
|
||||||
filters << (is_positive ?
|
filters << (is_positive ?
|
||||||
Filter.restricts(value, locale) :
|
Filter.restricts(value) :
|
||||||
Filter.not_restricts(value, locale))
|
Filter.not_restricts(value))
|
||||||
when 'fits'
|
when 'fits'
|
||||||
raise NotImplementedError if value[:alt_style_id].present?
|
raise NotImplementedError if value[:alt_style_id].present?
|
||||||
pet_type = load_pet_type_by_color_and_species(
|
pet_type = load_pet_type_by_color_and_species(
|
||||||
|
@ -209,12 +203,12 @@ class Item
|
||||||
"#<#{self.class.name} #{@text.inspect}>"
|
"#<#{self.class.name} #{@text.inspect}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.name_includes(value, locale)
|
def self.name_includes(value)
|
||||||
self.new Item.name_includes(value, locale), "#{q value}"
|
self.new Item.name_includes(value), "#{q value}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.name_excludes(value, locale)
|
def self.name_excludes(value)
|
||||||
self.new Item.name_excludes(value, locale), "-#{q value}"
|
self.new Item.name_excludes(value), "-#{q value}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.occupies(value)
|
def self.occupies(value)
|
||||||
|
|
Loading…
Reference in a new issue