* Update test csvs * Fix count filters and refactor apply_filters * Update party_querying_concern.rb * +tests/-debug logs * Make party association optional in Job * Updates for weapon series - Change to new series numbers - Add static method for querying whether the weapon's element is changeable - Add a new method to return a text slug for the weapon's series * Add and update test data - Updates canonical.rb for loading multiple types of data with multiple types of associations - Adds test data for Guidebooks, Job Accessories, Job Skills, and Jobs - Updates test data for Weapons and Summons * Migrations - Adds series of migrations for changing the weapon's series to the values used by Cygames - Shuffled around some foreign keys * Implement BaseProcessor Processors are in charge of processing deck data straight from Granblue. * Implement CharacterProcessor Process character data from deck * Implement WeaponProcessor Process weapon data from deck * Implement JobProcessor Process job, job skill, and job accessory data from deck * Implement SummonProcessor Process summon data from deck * Update SummonProcessor to work like the others * ImportController should use processors * Process element for changeable weapons
62 lines
1.7 KiB
Ruby
62 lines
1.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module PartyQueryingConcern
|
|
extend ActiveSupport::Concern
|
|
include PartyConstants
|
|
|
|
# Returns the common base query for Parties including all necessary associations.
|
|
def build_common_base_query
|
|
Party.includes(
|
|
{ raid: :group },
|
|
:job,
|
|
:user,
|
|
:skill0,
|
|
:skill1,
|
|
:skill2,
|
|
:skill3,
|
|
:guidebook1,
|
|
:guidebook2,
|
|
:guidebook3,
|
|
{ characters: :character },
|
|
{ weapons: :weapon },
|
|
{ summons: :summon }
|
|
)
|
|
end
|
|
|
|
# Uses PartyQueryBuilder to apply additional filters (includes, excludes, date ranges, etc.)
|
|
def build_filtered_query(base_query)
|
|
PartyQueryBuilder.new(base_query,
|
|
params: params,
|
|
current_user: current_user,
|
|
options: { apply_defaults: true }).build
|
|
end
|
|
|
|
# Renders paginated parties using PartyBlueprint.
|
|
def render_paginated_parties(parties)
|
|
render json: Api::V1::PartyBlueprint.render(
|
|
parties,
|
|
view: :preview,
|
|
root: :results,
|
|
meta: {
|
|
count: parties.total_entries,
|
|
total_pages: parties.total_pages,
|
|
per_page: COLLECTION_PER_PAGE
|
|
},
|
|
current_user: current_user
|
|
)
|
|
end
|
|
|
|
# Returns a remixed party name based on the current party name and current_user language.
|
|
def remixed_name(name)
|
|
blanked_name = { en: name.blank? ? 'Untitled team' : name, ja: name.blank? ? '無名の編成' : name }
|
|
if current_user
|
|
case current_user.language
|
|
when 'en' then "Remix of #{blanked_name[:en]}"
|
|
when 'ja' then "#{blanked_name[:ja]}のリミックス"
|
|
else "Remix of #{blanked_name[:en]}"
|
|
end
|
|
else
|
|
"Remix of #{blanked_name[:en]}"
|
|
end
|
|
end
|
|
end
|