hensei-api/app/models/job.rb
Justin Edmund c3d9efa349
Job accessories backend support (#206)
* add jobs search endpoint with pg_search

- add en_search and ja_search scopes to Job model
- add jobs action to SearchController with filtering
- supports row, proficiency, master_level, ultimate_mastery, accessory filters

* add jobs create endpoint

* add job accessories CRUD

- add accessory_type to blueprint
- add index, show, create, update, destroy actions
- editors only for mutations

* add routes for jobs search, create, and accessories CRUD
2026-01-04 14:47:27 -08:00

47 lines
1.1 KiB
Ruby

# frozen_string_literal: true
class Job < ApplicationRecord
include PgSearch::Model
belongs_to :party, optional: true
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
}
}
pg_search_scope :en_search,
against: :name_en,
using: {
tsearch: {
prefix: true
}
}
pg_search_scope :ja_search,
against: :name_jp,
using: {
tsearch: {
prefix: true
}
}
belongs_to :base_job,
foreign_key: 'base_job_id',
class_name: 'Job',
optional: true
def blueprint
JobBlueprint
end
def display_resource(job)
job.name_en
end
end