Make models multisearchable
We're going to start with Character, Summon, Weapon and Jobs
This commit is contained in:
parent
a2ac1ee1b0
commit
cca316bb57
4 changed files with 42 additions and 0 deletions
|
|
@ -3,6 +3,16 @@
|
||||||
class Character < ApplicationRecord
|
class Character < ApplicationRecord
|
||||||
include PgSearch::Model
|
include PgSearch::Model
|
||||||
|
|
||||||
|
multisearchable against: %i[name_en name_jp],
|
||||||
|
additional_attributes: lambda { |character|
|
||||||
|
{
|
||||||
|
name_en: character.name_en,
|
||||||
|
name_jp: character.name_jp,
|
||||||
|
granblue_id: character.granblue_id,
|
||||||
|
element: character.element
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pg_search_scope :en_search,
|
pg_search_scope :en_search,
|
||||||
against: :name_en,
|
against: :name_en,
|
||||||
using: {
|
using: {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,21 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Job < ApplicationRecord
|
class Job < ApplicationRecord
|
||||||
|
include PgSearch::Model
|
||||||
|
|
||||||
belongs_to :party
|
belongs_to :party
|
||||||
has_many :skills, class_name: 'JobSkill'
|
has_many :skills, class_name: 'JobSkill'
|
||||||
|
|
||||||
|
multisearchable against: %i[name_en name_jp],
|
||||||
|
additional_attributes: lambda { |job|
|
||||||
|
{
|
||||||
|
name_en: job.name_en,
|
||||||
|
name_jp: job.name_jp,
|
||||||
|
granblue_id: job.granblue_id,
|
||||||
|
element: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
belongs_to :base_job,
|
belongs_to :base_job,
|
||||||
foreign_key: 'base_job_id',
|
foreign_key: 'base_job_id',
|
||||||
class_name: 'Job',
|
class_name: 'Job',
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,16 @@
|
||||||
class Summon < ApplicationRecord
|
class Summon < ApplicationRecord
|
||||||
include PgSearch::Model
|
include PgSearch::Model
|
||||||
|
|
||||||
|
multisearchable against: %i[name_en name_jp],
|
||||||
|
additional_attributes: lambda { |summon|
|
||||||
|
{
|
||||||
|
name_en: summon.name_en,
|
||||||
|
name_jp: summon.name_jp,
|
||||||
|
granblue_id: summon.granblue_id,
|
||||||
|
element: summon.element
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pg_search_scope :en_search,
|
pg_search_scope :en_search,
|
||||||
against: :name_en,
|
against: :name_en,
|
||||||
using: {
|
using: {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,16 @@
|
||||||
class Weapon < ApplicationRecord
|
class Weapon < ApplicationRecord
|
||||||
include PgSearch::Model
|
include PgSearch::Model
|
||||||
|
|
||||||
|
multisearchable against: %i[name_en name_jp],
|
||||||
|
additional_attributes: lambda { |weapon|
|
||||||
|
{
|
||||||
|
name_en: weapon.name_en,
|
||||||
|
name_jp: weapon.name_jp,
|
||||||
|
granblue_id: weapon.granblue_id,
|
||||||
|
element: weapon.element
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pg_search_scope :en_search,
|
pg_search_scope :en_search,
|
||||||
against: :name_en,
|
against: :name_en,
|
||||||
using: {
|
using: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue