hensei-api/app/models/weapon.rb
Justin Edmund 4567766530
Fix searching in Japanese (#99)
This was broken because we were using the browser-provided locale as a prefix to our method, but that is 'ja' and our methods were prefixed with 'jp'.
2023-06-18 23:43:50 -07:00

39 lines
849 B
Ruby

# frozen_string_literal: true
class Weapon < ApplicationRecord
include PgSearch::Model
pg_search_scope :en_search,
against: :name_en,
using: {
trigram: {
threshold: 0.18
}
}
pg_search_scope :ja_search,
against: :name_jp,
using: {
tsearch: {
prefix: true,
dictionary: 'simple'
}
}
def blueprint
WeaponBlueprint
end
def display_resource(weapon)
weapon.name_en
end
def compatible_with_key?(key)
key.series == series
end
# Returns whether the weapon is included in the Draconic or Dark Opus series
def opus_or_draconic?
[2, 3].include?(series)
end
end