Merge pull request #14 from jedmund/class

Add support for selecting Jobs for teams
This commit is contained in:
Justin Edmund 2022-04-10 13:33:13 -07:00 committed by GitHub
commit 05f6ecc1c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 210 additions and 10 deletions

View file

@ -0,0 +1,6 @@
class Api::V1::JobsController < Api::V1::ApiController
def all
@jobs = Job.all()
render :all, status: :ok
end
end

View file

@ -118,6 +118,6 @@ class Api::V1::PartiesController < Api::V1::ApiController
end
def party_params
params.require(:party).permit(:user_id, :extra, :name, :description, :raid_id)
params.require(:party).permit(:user_id, :extra, :name, :description, :raid_id, :job_id)
end
end

View file

@ -97,7 +97,7 @@ class Api::V1::UsersController < Api::V1::ApiController
def user_params
params.require(:user).permit(
:username, :email, :password, :password_confirmation,
:granblue_id, :picture, :element, :language, :private
:granblue_id, :picture, :element, :language, :gender, :private
)
end
end

7
app/models/job.rb Normal file
View file

@ -0,0 +1,7 @@
class Job < ApplicationRecord
belongs_to :party
def display_resource(job)
job.name_en
end
end

View file

@ -2,6 +2,7 @@ class Party < ApplicationRecord
##### ActiveRecord Associations
belongs_to :user, optional: true
belongs_to :raid, optional: true
belongs_to :job, optional: true
has_many :characters,
foreign_key: "party_id",

View file

@ -0,0 +1,3 @@
collection @jobs, object_root: false
extends 'jobs/base'

View file

@ -0,0 +1,17 @@
object :job
attributes :id, :row, :ml, :order
node :name do |j|
{
:en => j.name_en,
:ja => j.name_jp
}
end
node :proficiency do |j|
[
j.proficiency1,
j.proficiency2
]
end

View file

@ -14,6 +14,10 @@ node :raid do |p|
partial('raids/base', :object => p.raid)
end
node :job do |p|
partial('jobs/base', :object => p.job)
end
node :characters do |p|
partial('grid_characters/base', :object => p.characters)
end

View file

@ -4,7 +4,8 @@ attributes :id,
:username,
:granblue_id,
:language,
:private
:private,
:gender
node :picture do |u|
{

View file

@ -26,6 +26,7 @@ Rails.application.routes.draw do
post 'search/weapons', to: 'search#weapons'
post 'search/summons', to: 'search#summons'
get 'jobs', to: 'jobs#all'
get 'raids', to: 'raids#all'
get 'weapon_keys', to: 'weapon_keys#all'

View file

@ -0,0 +1,14 @@
class CreateClasses < ActiveRecord::Migration[6.0]
def change
create_table :classes, id: :uuid, default: -> { "gen_random_uuid()" } do |t|
t.string :name_en
t.string :name_jp
t.integer :proficiency1
t.integer :proficiency2
t.string :row
t.boolean :ml, default: false
end
end
end

View file

@ -0,0 +1,6 @@
class AddClassAndMlToParty < ActiveRecord::Migration[6.1]
def change
add_reference :parties, :class, name: :class_id, type: :uuid, foreign_key: { to_table: :classes }
add_column :parties, :ml, :integer
end
end

View file

@ -0,0 +1,6 @@
class AddForeignKeyRelationsToParties < ActiveRecord::Migration[6.1]
def change
add_foreign_key :parties, :users
add_foreign_key :parties, :raids
end
end

View file

@ -0,0 +1,6 @@
class AddForeignKeyRelationsToFavorites < ActiveRecord::Migration[6.1]
def change
add_foreign_key :favorites, :users
add_foreign_key :favorites, :parties
end
end

View file

@ -0,0 +1,12 @@
class AddForeignKeyRelationsToObjects < ActiveRecord::Migration[6.1]
def change
add_foreign_key :grid_characters, :parties
add_foreign_key :grid_characters, :characters
add_foreign_key :grid_weapons, :parties
add_foreign_key :grid_weapons, :weapons
add_foreign_key :grid_summons, :parties
add_foreign_key :grid_summons, :summons
end
end

View file

@ -0,0 +1,14 @@
class AddDefaultPerpetuityToGridCharacters < ActiveRecord::Migration[6.1]
def up
GridCharacter.find_each do |char|
char.perpetuity = false
char.save!
end
change_column :grid_characters, :perpetuity, :boolean, default: false, null: false
end
def down
end
end

View file

@ -0,0 +1,9 @@
class AddDefaultsToCharacters < ActiveRecord::Migration[6.1]
def up
change_column :characters, :flb, :boolean, default: false, null: false
end
def down
end
end

View file

@ -0,0 +1,24 @@
class AddDefaultsToWeapons < ActiveRecord::Migration[6.1]
def up
Weapon.find_each do |w|
if w.flb.nil?
w.flb = false
w.save!
end
if w.ulb.nil?
w.ulb = false
w.save!
end
end
change_column :weapons, :flb, :boolean, default: false, null: false
change_column :weapons, :ulb, :boolean, default: false, null: false
change_column :weapons, :ax, :integer, default: 0, null: false
change_column :weapons, :series, :integer, default: -1, null: false
end
def down
end
end

View file

@ -0,0 +1,24 @@
class AddDefaultsToSummons < ActiveRecord::Migration[6.1]
def change
def up
Summon.find_each do |s|
if s.flb.nil?
s.flb = false
s.save!
end
if s.ulb.nil?
s.ulb = false
s.save!
end
end
change_column :summons, :flb, :boolean, default: false, null: false
change_column :summons, :ulb, :boolean, default: false, null: false
end
def down
end
end
end

View file

@ -0,0 +1,5 @@
class ChangeClassesToJobs < ActiveRecord::Migration[6.1]
def change
rename_table :classes, :jobs
end
end

View file

@ -0,0 +1,5 @@
class RenameClassIdToJobId < ActiveRecord::Migration[6.1]
def change
rename_column :parties, :class_id, :job_id
end
end

View file

@ -0,0 +1,5 @@
class AddOrderToJobs < ActiveRecord::Migration[6.1]
def change
add_column :jobs, :order, :integer
end
end

View file

@ -0,0 +1,5 @@
class AddGenderToUser < ActiveRecord::Migration[6.1]
def change
add_column :users, :gender, :integer, null: false, default: 0
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_03_15_011802) do
ActiveRecord::Schema.define(version: 2022_04_10_190152) do
# These are extensions that must be enabled in order to support this database
enable_extension "btree_gin"
@ -29,7 +29,7 @@ ActiveRecord::Schema.define(version: 2022_03_15_011802) do
t.integer "gender"
t.integer "race1"
t.integer "race2"
t.boolean "flb", null: false
t.boolean "flb", default: false, null: false
t.integer "min_hp"
t.integer "max_hp"
t.integer "max_hp_flb"
@ -63,7 +63,7 @@ ActiveRecord::Schema.define(version: 2022_03_15_011802) do
t.integer "position"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.boolean "perpetuity"
t.boolean "perpetuity", default: false, null: false
t.index ["character_id"], name: "index_grid_characters_on_character_id"
t.index ["party_id"], name: "index_grid_characters_on_party_id"
end
@ -101,6 +101,16 @@ ActiveRecord::Schema.define(version: 2022_03_15_011802) do
t.index ["weapon_id"], name: "index_grid_weapons_on_weapon_id"
end
create_table "jobs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "name_en"
t.string "name_jp"
t.integer "proficiency1"
t.integer "proficiency2"
t.string "row"
t.boolean "ml", default: false
t.integer "order"
end
create_table "oauth_access_grants", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "resource_owner_id", null: false
t.uuid "application_id", null: false
@ -150,6 +160,9 @@ ActiveRecord::Schema.define(version: 2022_03_15_011802) do
t.uuid "raid_id"
t.integer "element"
t.integer "weapons_count"
t.uuid "job_id"
t.integer "ml"
t.index ["job_id"], name: "index_parties_on_job_id"
t.index ["user_id"], name: "index_parties_on_user_id"
end
@ -196,6 +209,7 @@ ActiveRecord::Schema.define(version: 2022_03_15_011802) do
t.string "language", default: "en", null: false
t.boolean "private", default: false, null: false
t.string "element", default: "water", null: false
t.integer "gender", default: 0, null: false
end
create_table "weapon_keys", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
@ -214,9 +228,9 @@ ActiveRecord::Schema.define(version: 2022_03_15_011802) do
t.integer "rarity"
t.integer "element"
t.integer "proficiency"
t.integer "series"
t.boolean "flb"
t.boolean "ulb"
t.integer "series", default: -1, null: false
t.boolean "flb", default: false, null: false
t.boolean "ulb", default: false, null: false
t.integer "max_level"
t.integer "max_skill_level"
t.integer "min_hp"
@ -229,11 +243,22 @@ ActiveRecord::Schema.define(version: 2022_03_15_011802) do
t.integer "max_atk_ulb"
t.boolean "extra", default: false, null: false
t.integer "limit"
t.integer "ax"
t.integer "ax", default: 0, null: false
t.index ["name_en"], name: "index_weapons_on_name_en", opclass: :gin_trgm_ops, using: :gin
end
add_foreign_key "favorites", "parties"
add_foreign_key "favorites", "users"
add_foreign_key "grid_characters", "characters"
add_foreign_key "grid_characters", "parties"
add_foreign_key "grid_summons", "parties"
add_foreign_key "grid_summons", "summons"
add_foreign_key "grid_weapons", "parties"
add_foreign_key "grid_weapons", "weapon_keys", column: "weapon_key3_id"
add_foreign_key "grid_weapons", "weapons"
add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id"
add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id"
add_foreign_key "parties", "jobs"
add_foreign_key "parties", "raids"
add_foreign_key "parties", "users"
end