Support for Siero, raids rework and edit party rework (#96)
* Add guidebooks migration * Implement business logic for reading Guidebooks * Change to individual guidebook columns * Properly output guidebook description * Move to 1-index guidebooks * Update party-related files for 1-index guidebooks * Add tables for Siero * Add raid groups table * Update raid model To belong to the RaidGroup class * Update job class To have many job skills * Add endpoint for raid groups * Update Raid blueprint with views * Added down for creating table * Add guidebooks flag and auto summon flag * Guidebooks → RaidGroup * Auto summon → Party * Add views to Raid blueprint * Add views and guidebook flag to RaidGroup blueprint * Add auto summon and Raid view to Party blueprint
This commit is contained in:
parent
190b5b29ea
commit
56ccbe3dbb
16 changed files with 132 additions and 12 deletions
|
|
@ -34,7 +34,8 @@ module Api
|
||||||
|
|
||||||
view :minimal do
|
view :minimal do
|
||||||
fields :name, :element, :shortcode, :favorited, :extra,
|
fields :name, :element, :shortcode, :favorited, :extra,
|
||||||
:full_auto, :clear_time, :auto_guard, :created_at, :updated_at
|
:full_auto, :clear_time, :auto_guard, :auto_summon,
|
||||||
|
:created_at, :updated_at
|
||||||
|
|
||||||
field :remix do |p|
|
field :remix do |p|
|
||||||
p.is_remix
|
p.is_remix
|
||||||
|
|
@ -49,7 +50,8 @@ module Api
|
||||||
end
|
end
|
||||||
|
|
||||||
association :raid,
|
association :raid,
|
||||||
blueprint: RaidBlueprint
|
blueprint: RaidBlueprint,
|
||||||
|
view: :full
|
||||||
|
|
||||||
association :job,
|
association :job,
|
||||||
blueprint: JobBlueprint
|
blueprint: JobBlueprint
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,21 @@
|
||||||
module Api
|
module Api
|
||||||
module V1
|
module V1
|
||||||
class RaidBlueprint < ApiBlueprint
|
class RaidBlueprint < ApiBlueprint
|
||||||
field :name do |raid|
|
view :nested do
|
||||||
{
|
field :name do |raid|
|
||||||
en: raid.name_en,
|
{
|
||||||
ja: raid.name_jp
|
en: raid.name_en,
|
||||||
}
|
ja: raid.name_jp
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
fields :slug, :level, :element
|
||||||
end
|
end
|
||||||
|
|
||||||
fields :slug, :level, :group, :element
|
view :full do
|
||||||
|
include_view :nested
|
||||||
|
association :group, blueprint: RaidGroupBlueprint, view: :flat
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
23
app/blueprints/api/v1/raid_group_blueprint.rb
Normal file
23
app/blueprints/api/v1/raid_group_blueprint.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Api
|
||||||
|
module V1
|
||||||
|
class RaidGroupBlueprint < ApiBlueprint
|
||||||
|
view :flat do
|
||||||
|
field :name do |group|
|
||||||
|
{
|
||||||
|
en: group.name_en,
|
||||||
|
ja: group.name_jp
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
fields :difficulty, :order, :section, :extra, :guidebooks, :hl
|
||||||
|
end
|
||||||
|
|
||||||
|
view :full do
|
||||||
|
include_view :flat
|
||||||
|
association :raids, blueprint: RaidBlueprint, view: :full
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -56,7 +56,7 @@ module Api
|
||||||
# TODO: Validate accessory with job
|
# TODO: Validate accessory with job
|
||||||
|
|
||||||
return render json: PartyBlueprint.render(@party, view: :full, root: :party) if @party.save
|
return render json: PartyBlueprint.render(@party, view: :full, root: :party) if @party.save
|
||||||
|
|
||||||
render_validation_error_response(@party)
|
render_validation_error_response(@party)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -259,6 +259,7 @@ module Api
|
||||||
:skill3_id,
|
:skill3_id,
|
||||||
:full_auto,
|
:full_auto,
|
||||||
:auto_guard,
|
:auto_guard,
|
||||||
|
:auto_summon,
|
||||||
:charge_attack,
|
:charge_attack,
|
||||||
:clear_time,
|
:clear_time,
|
||||||
:button_count,
|
:button_count,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@ module Api
|
||||||
module V1
|
module V1
|
||||||
class RaidsController < Api::V1::ApiController
|
class RaidsController < Api::V1::ApiController
|
||||||
def all
|
def all
|
||||||
render json: RaidBlueprint.render(Raid.all)
|
render json: RaidBlueprint.render(Raid.all, view: :full)
|
||||||
|
end
|
||||||
|
|
||||||
|
def groups
|
||||||
|
render json: RaidGroupBlueprint.render(RaidGroup.all, view: :full)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
class Job < ApplicationRecord
|
class Job < ApplicationRecord
|
||||||
belongs_to :party
|
belongs_to :party
|
||||||
|
has_many :skills, class_name: 'JobSkill'
|
||||||
|
|
||||||
belongs_to :base_job,
|
belongs_to :base_job,
|
||||||
foreign_key: 'base_job_id',
|
foreign_key: 'base_job_id',
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Raid < ApplicationRecord
|
class Raid < ApplicationRecord
|
||||||
|
belongs_to :group, class_name: 'RaidGroup', foreign_key: :group_id
|
||||||
|
|
||||||
def blueprint
|
def blueprint
|
||||||
RaidBlueprint
|
RaidBlueprint
|
||||||
end
|
end
|
||||||
|
|
|
||||||
9
app/models/raid_group.rb
Normal file
9
app/models/raid_group.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class RaidGroup < ApplicationRecord
|
||||||
|
has_many :raids, class_name: 'Raid', foreign_key: :group_id
|
||||||
|
|
||||||
|
def blueprint
|
||||||
|
RaidGroupBlueprint
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -45,6 +45,7 @@ Rails.application.routes.draw do
|
||||||
get 'guidebooks', to: 'guidebooks#all'
|
get 'guidebooks', to: 'guidebooks#all'
|
||||||
|
|
||||||
get 'raids', to: 'raids#all'
|
get 'raids', to: 'raids#all'
|
||||||
|
get 'raids/groups', to: 'raids#groups'
|
||||||
get 'weapon_keys', to: 'weapon_keys#all'
|
get 'weapon_keys', to: 'weapon_keys#all'
|
||||||
|
|
||||||
post 'characters', to: 'grid_characters#create'
|
post 'characters', to: 'grid_characters#create'
|
||||||
|
|
|
||||||
16
db/migrate/20230529210259_add_raid_groups_table.rb
Normal file
16
db/migrate/20230529210259_add_raid_groups_table.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
class AddRaidGroupsTable < ActiveRecord::Migration[7.0]
|
||||||
|
def up
|
||||||
|
create_table :raid_groups, id: :uuid, default: -> { "gen_random_uuid()" } do |t|
|
||||||
|
t.string :name_en, null: false
|
||||||
|
t.string :name_jp, null: false
|
||||||
|
t.integer :difficulty
|
||||||
|
t.integer :order, null: false
|
||||||
|
t.integer :section, default: 1, null: false
|
||||||
|
t.boolean :extra, default: false, null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
drop_table :raid_groups
|
||||||
|
end
|
||||||
|
end
|
||||||
6
db/migrate/20230529215259_add_raid_group_to_raids.rb
Normal file
6
db/migrate/20230529215259_add_raid_group_to_raids.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
class AddRaidGroupToRaids < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_reference :raids, :group, null: true, to_table: 'raid_groups', type: :uuid
|
||||||
|
add_foreign_key :raids, :raid_groups, column: :group_id
|
||||||
|
end
|
||||||
|
end
|
||||||
5
db/migrate/20230530000739_add_hl_to_raid_groups.rb
Normal file
5
db/migrate/20230530000739_add_hl_to_raid_groups.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddHlToRaidGroups < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_column :raid_groups, :hl, :boolean, default: true, null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
class RemoveGroupIntegerFromRaids < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
remove_column :raids, :group, :integer
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddGuidebooksToRaidGroups < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_column :raid_groups, :guidebooks, :boolean, default: false, null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
5
db/migrate/20230618051638_add_auto_summon_to_parties.rb
Normal file
5
db/migrate/20230618051638_add_auto_summon_to_parties.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddAutoSummonToParties < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_column :parties, :auto_summon, :boolean, default: false, null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
32
db/schema.rb
32
db/schema.rb
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.0].define(version: 2023_05_03_224353) do
|
ActiveRecord::Schema[7.0].define(version: 2023_06_18_051638) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "btree_gin"
|
enable_extension "btree_gin"
|
||||||
enable_extension "pg_trgm"
|
enable_extension "pg_trgm"
|
||||||
|
|
@ -332,6 +332,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_03_224353) do
|
||||||
t.uuid "guidebook3_id"
|
t.uuid "guidebook3_id"
|
||||||
t.uuid "guidebook1_id"
|
t.uuid "guidebook1_id"
|
||||||
t.uuid "guidebook2_id"
|
t.uuid "guidebook2_id"
|
||||||
|
t.boolean "auto_summon", default: false, null: false
|
||||||
t.index ["accessory_id"], name: "index_parties_on_accessory_id"
|
t.index ["accessory_id"], name: "index_parties_on_accessory_id"
|
||||||
t.index ["guidebook1_id"], name: "index_parties_on_guidebook1_id"
|
t.index ["guidebook1_id"], name: "index_parties_on_guidebook1_id"
|
||||||
t.index ["guidebook2_id"], name: "index_parties_on_guidebook2_id"
|
t.index ["guidebook2_id"], name: "index_parties_on_guidebook2_id"
|
||||||
|
|
@ -345,13 +346,39 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_03_224353) do
|
||||||
t.index ["user_id"], name: "index_parties_on_user_id"
|
t.index ["user_id"], name: "index_parties_on_user_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "raid_groups", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||||
|
t.string "name_en", null: false
|
||||||
|
t.string "name_jp", null: false
|
||||||
|
t.integer "difficulty"
|
||||||
|
t.integer "order", null: false
|
||||||
|
t.integer "section", default: 1, null: false
|
||||||
|
t.boolean "extra", default: false, null: false
|
||||||
|
t.boolean "hl", default: true, null: false
|
||||||
|
t.boolean "guidebooks", default: false, null: false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "raids", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
create_table "raids", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||||
t.string "name_en"
|
t.string "name_en"
|
||||||
t.string "name_jp"
|
t.string "name_jp"
|
||||||
t.integer "level"
|
t.integer "level"
|
||||||
t.integer "group"
|
|
||||||
t.integer "element"
|
t.integer "element"
|
||||||
t.string "slug"
|
t.string "slug"
|
||||||
|
t.uuid "group_id"
|
||||||
|
t.index ["group_id"], name: "index_raids_on_group_id"
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "sparks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||||
|
t.string "user_id", null: false
|
||||||
|
t.string "guild_ids", null: false, array: true
|
||||||
|
t.integer "crystals", default: 0
|
||||||
|
t.integer "tickets", default: 0
|
||||||
|
t.integer "ten_tickets", default: 0
|
||||||
|
t.string "target_type"
|
||||||
|
t.bigint "target_id"
|
||||||
|
t.datetime "updated_at", default: -> { "CURRENT_TIMESTAMP" }, null: false
|
||||||
|
t.string "target_memo"
|
||||||
|
t.index ["target_type", "target_id"], name: "index_sparks_on_target"
|
||||||
|
t.index ["user_id"], name: "index_sparks_on_user_id", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "sparks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
create_table "sparks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||||
|
|
@ -479,4 +506,5 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_03_224353) do
|
||||||
add_foreign_key "parties", "parties", column: "source_party_id"
|
add_foreign_key "parties", "parties", column: "source_party_id"
|
||||||
add_foreign_key "parties", "raids"
|
add_foreign_key "parties", "raids"
|
||||||
add_foreign_key "parties", "users"
|
add_foreign_key "parties", "users"
|
||||||
|
add_foreign_key "raids", "raid_groups", column: "group_id"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue