* Remove ap call * Fix remix render method * Downcase username on db end There was a bug where users with capital letters in their name could not access their profiles after we tried to make things case insensitive. * Remove ap call and unused code * Add granblue.team to cors This works now! * Implement all-entity search to support tagging objects (#117) * Add table for multisearch * Add new route for searching all entities * Make models multisearchable We're going to start with Character, Summon, Weapon and Jobs * Add method to Search controller This will search with trigram first, and then if there aren't enough results, search with prefixed text search * Add support for Japanese all-entity search * Update grid_summons_controller.rb Set the proper uncap level for transcended summons * Search is broken in Japanese! * Grid model object updates * Adds has_one association to canonical objects * GridWeapon is_mainhand refactored * GridCharacter add_awakening refactored * (WIP) Add support for inclusion/exclusion + refactor This commit adds basic support for including/excluding objects from collection filters. There is also a refactor of the filter logic as a whole. It is only implemented in `teams` for now and is a work in progress. * Update multisearch for exclusions * Add nicknames to the index for multisearchable
115 lines
2.5 KiB
Ruby
115 lines
2.5 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class Character < ApplicationRecord
|
|
include PgSearch::Model
|
|
|
|
multisearchable against: %i[name_en name_jp],
|
|
additional_attributes: lambda { |character|
|
|
{
|
|
name_en: character.name_en,
|
|
name_jp: character.name_jp,
|
|
nicknames_en: character.nicknames_en,
|
|
nicknames_jp: character.nicknames_jp,
|
|
granblue_id: character.granblue_id,
|
|
element: character.element
|
|
}
|
|
}
|
|
|
|
pg_search_scope :en_search,
|
|
against: %i[name_en nicknames_en],
|
|
using: {
|
|
tsearch: {
|
|
prefix: true,
|
|
dictionary: 'simple'
|
|
},
|
|
trigram: {
|
|
threshold: 0.18
|
|
}
|
|
}
|
|
|
|
pg_search_scope :ja_search,
|
|
against: %i[name_jp nicknames_jp],
|
|
using: {
|
|
tsearch: {
|
|
prefix: true,
|
|
dictionary: 'simple'
|
|
}
|
|
}
|
|
|
|
def blueprint
|
|
CharacterBlueprint
|
|
end
|
|
|
|
def display_resource(character)
|
|
character.name_en
|
|
end
|
|
|
|
# enum rarities: {
|
|
# R: 1,
|
|
# SR: 2,
|
|
# SSR: 3
|
|
# }
|
|
|
|
# enum elements: {
|
|
# Null: 0,
|
|
# Wind: 1,
|
|
# Fire: 2,
|
|
# Water: 3,
|
|
# Earth: 4,
|
|
# Dark: 5,
|
|
# Light: 6
|
|
# }
|
|
|
|
# enum proficiency1s: {
|
|
# Sabre: 1,
|
|
# Dagger: 2,
|
|
# Axe: 3,
|
|
# Spear: 4,
|
|
# Bow: 5,
|
|
# Staff: 6,
|
|
# Melee: 7,
|
|
# Harp: 8,
|
|
# Gun: 9,
|
|
# Katana: 10
|
|
# }, _prefix: "proficiency1"
|
|
|
|
# enum proficiency2s: {
|
|
# None: 0,
|
|
# Sabre: 1,
|
|
# Dagger: 2,
|
|
# Axe: 3,
|
|
# Spear: 4,
|
|
# Bow: 5,
|
|
# Staff: 6,
|
|
# Melee: 7,
|
|
# Harp: 8,
|
|
# Gun: 9,
|
|
# Katana: 10,
|
|
# }, _default: :None, _prefix: "proficiency2"
|
|
|
|
# enum race1s: {
|
|
# Unknown: 0,
|
|
# Human: 1,
|
|
# Erune: 2,
|
|
# Draph: 3,
|
|
# Harvin: 4,
|
|
# Primal: 5
|
|
# }, _prefix: "race1"
|
|
|
|
# enum race2s: {
|
|
# Unknown: 0,
|
|
# Human: 1,
|
|
# Erune: 2,
|
|
# Draph: 3,
|
|
# Harvin: 4,
|
|
# Primal: 5,
|
|
# None: 6
|
|
# }, _default: :None, _prefix: "race2"
|
|
|
|
# enum gender: {
|
|
# Unknown: 0,
|
|
# Male: 1,
|
|
# Female: 2,
|
|
# "Male/Female": 3
|
|
# }
|
|
end
|