From d587ceeeec1e0083967bfcb501808492231d4696 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 5 Feb 2023 00:56:27 -0800 Subject: [PATCH 1/6] Small Rails 7 configuration changes (#72) --- .gitignore | 2 ++ config/credentials.yml.enc | 2 +- db/schema.rb | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3f3248c..7f0b053 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,5 @@ config/application.yml .idea/* .vscode/* + +/config/credentials/production.key diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index bab8787..719ac75 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -d2FydGGNzmcDxx3yD8kWlU7vquTJA/QHjPxZhjcoV65DZYU2JgRZSwL+zzE+Vl4bfXtkHKXhyI821y2DvcCtFpHPmNuUncmvmt+jq9mkrK1KuQts9FLshzw1JdCDioGr+JUmMmb55nPChtHUTnd+eW7BXi9KfBtogA9vDlkEG47epYKv0Wn99ziOP/fyvIPVC+nRtUePHQvDAqIENK7doHDKoDhNkhYbCNwH8Xa+F+kZNVKMgpyoCkNDPg10NyUhub7rHBEX41xGeluZVGAkG6HsBB1XNHAkyCQroBKh/XTHZ4brCTeaoJHL3W+/nwZrRDnBVWl7p6lh17JGgfmTzx/oNBqk/FJHR9lfAdkh/msrqpl5YlnsB9nY6vmjEEX4epylGYWDndoo0INYLawOZp1xFgQFedPb7ZU5--f6jX9dWlDgeyy6gd--nHpeshtZQBL1eBzNeocBoA== \ No newline at end of file +Fxc8acnxWOFdt+zwWoACR/fskFH2+ZY5izq5cHf8pnGDKRSoI7QYm0h8RwevJtRUvUJQsJ+ja/xzbTYxNC4ABRSBe06lXwHJuCnt5YtR+4l+NiFnS76kGzSfhlfhmvPLtSdfTVRfhRib1vrz7E38jM1pcc2QBkzCxyaoZRu3X65U+gc7EqTjOsg8wpTjJwvfTXW9gkFNwFSen3nOSytewYDcivwUjr/3NUAONKHn4rNhBN3UJiNgOSCGj77Xx60E0Q95CidbkgExcyKAIMMsQgLKGhQRr9yUGxdshMuhA3JhVQSyvtd+jX8PmNX3FQusQIg7YUCh/WpiKo3aimZLQYY2n7lbfeSLpwuishjn138GAxe59Wgm1JhKN4xAkcAq54Q9d4AGFnu/IphMhv1TO03CqnwX1BbfY142--n8Fil7/q3W/SrENe--J31ORG+51iIo29fjiZU3Uw== \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index 2e115d4..bd7970e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -53,6 +53,9 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_31_084343) do t.index ["name_en"], name: "index_characters_on_name_en", opclass: :gin_trgm_ops, using: :gin end + create_table "data_migrations", primary_key: "version", id: :string, force: :cascade do |t| + end + create_table "favorites", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "user_id" t.uuid "party_id" From e2c1639d8fe03c9334802fd0b649f527779f5f24 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 5 Feb 2023 15:49:09 -0800 Subject: [PATCH 2/6] Remove log call --- app/controllers/api/v1/grid_weapons_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/api/v1/grid_weapons_controller.rb b/app/controllers/api/v1/grid_weapons_controller.rb index 76b14f8..3f46061 100644 --- a/app/controllers/api/v1/grid_weapons_controller.rb +++ b/app/controllers/api/v1/grid_weapons_controller.rb @@ -185,7 +185,6 @@ module Api def authorize # Create - ap @party unauthorized_create = @party && (@party.user != current_user || @party.edit_key != edit_key) unauthorized_update = @weapon && @weapon.party && (@weapon.party.user != current_user || @weapon.party.edit_key != edit_key) From 158786b5a8ce3bb5163ad79581eeb316074e6f76 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 5 Feb 2023 16:32:57 -0800 Subject: [PATCH 3/6] Show EMP skills for Row 5 classes Row 4 EMP skills were not showing up, so you couldn't set Rage IV on Viking, for example --- app/controllers/api/v1/search_controller.rb | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb index 9792109..336704f 100644 --- a/app/controllers/api/v1/search_controller.rb +++ b/app/controllers/api/v1/search_controller.rb @@ -140,17 +140,27 @@ module Api # Perform the query skills = if search_params[:query].present? && search_params[:query].length >= 2 - JobSkill.method("#{locale}_search").call(search_params[:query]) + JobSkill.joins(:job) + .method("#{locale}_search").call(search_params[:query]) .where(conditions) .where(job: job.id, main: false) .or( - JobSkill.method("#{locale}_search").call(search_params[:query]) + JobSkill.joins(:job) + .method("#{locale}_search").call(search_params[:query]) .where(conditions) .where(sub: true) .where.not(job: job.id) ) + .or( + JobSkill.joins(:job) + .method("#{locale}_search").call(search_params[:query]) + .where(conditions) + .where(job: { base_job: job.base_job.id }, emp: true) + .where.not(job: job.id) + ) else JobSkill.all + .joins(:job) .where(conditions) .where(job: job.id, main: false) .or( @@ -165,6 +175,13 @@ module Api .where(job: job.base_job.id, base: true) .where.not(job: job.id) ) + .or( + JobSkill.all + .where(conditions) + .joins(:job) + .where(job: { base_job: job.base_job.id }, emp: true) + .where.not(job: job.id) + ) end count = skills.length From 472fb6816bfb34a472f157f826a1bd10c3e1840b Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 5 Feb 2023 16:41:54 -0800 Subject: [PATCH 4/6] Allow adding EMP skills from prior rows to team We let you search but didn't fix the server-side validation check for skills --- app/controllers/api/v1/jobs_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/jobs_controller.rb b/app/controllers/api/v1/jobs_controller.rb index 40276f8..443c080 100644 --- a/app/controllers/api/v1/jobs_controller.rb +++ b/app/controllers/api/v1/jobs_controller.rb @@ -150,7 +150,7 @@ module Api def mismatched_skill(job, skill) mismatched_main = (skill.job.id != job.id) && skill.main && !skill.sub - mismatched_emp = (skill.job.id != job.id) && skill.emp + mismatched_emp = (skill.job.id != job.id && skill.job.base_job.id != job.base_job.id) && skill.emp mismatched_base = skill.job.base_job && (job.row != 'ex2' || skill.job.base_job.id != job.base_job.id) && skill.base if %w[4 5 ex2].include?(job.row) From 2ef7b3025bc8783d59551ef6d4d56e89e74676db Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 16 Mar 2023 08:25:30 -0700 Subject: [PATCH 5/6] Allow anonymous users to edit remixed teams (#84) * Small Rails 7 configuration changes (#72) * Remove log call * Show EMP skills for Row 5 classes Row 4 EMP skills were not showing up, so you couldn't set Rage IV on Viking, for example * Allow adding EMP skills from prior rows to team We let you search but didn't fix the server-side validation check for skills * Show created view when remixing That will let anonymous users edit their remixed parties --- .../api/v1/grid_weapons_controller.rb | 1 - app/controllers/api/v1/jobs_controller.rb | 2 +- app/controllers/api/v1/parties_controller.rb | 2 +- app/controllers/api/v1/search_controller.rb | 21 +++++++++++++++++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/v1/grid_weapons_controller.rb b/app/controllers/api/v1/grid_weapons_controller.rb index 76b14f8..3f46061 100644 --- a/app/controllers/api/v1/grid_weapons_controller.rb +++ b/app/controllers/api/v1/grid_weapons_controller.rb @@ -185,7 +185,6 @@ module Api def authorize # Create - ap @party unauthorized_create = @party && (@party.user != current_user || @party.edit_key != edit_key) unauthorized_update = @weapon && @weapon.party && (@weapon.party.user != current_user || @weapon.party.edit_key != edit_key) diff --git a/app/controllers/api/v1/jobs_controller.rb b/app/controllers/api/v1/jobs_controller.rb index 40276f8..443c080 100644 --- a/app/controllers/api/v1/jobs_controller.rb +++ b/app/controllers/api/v1/jobs_controller.rb @@ -150,7 +150,7 @@ module Api def mismatched_skill(job, skill) mismatched_main = (skill.job.id != job.id) && skill.main && !skill.sub - mismatched_emp = (skill.job.id != job.id) && skill.emp + mismatched_emp = (skill.job.id != job.id && skill.job.base_job.id != job.base_job.id) && skill.emp mismatched_base = skill.job.base_job && (job.row != 'ex2' || skill.job.base_job.id != job.base_job.id) && skill.base if %w[4 5 ex2].include?(job.row) diff --git a/app/controllers/api/v1/parties_controller.rb b/app/controllers/api/v1/parties_controller.rb index d46fa63..a4f1221 100644 --- a/app/controllers/api/v1/parties_controller.rb +++ b/app/controllers/api/v1/parties_controller.rb @@ -65,7 +65,7 @@ module Api new_party.local_id = party_params[:local_id] if !party_params.nil? if new_party.save - render json: PartyBlueprint.render(new_party, view: :full, root: :party, + render json: PartyBlueprint.render(new_party, view: :created, root: :party, meta: { remix: true }) else render_validation_error_response(new_party) diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb index 9792109..336704f 100644 --- a/app/controllers/api/v1/search_controller.rb +++ b/app/controllers/api/v1/search_controller.rb @@ -140,17 +140,27 @@ module Api # Perform the query skills = if search_params[:query].present? && search_params[:query].length >= 2 - JobSkill.method("#{locale}_search").call(search_params[:query]) + JobSkill.joins(:job) + .method("#{locale}_search").call(search_params[:query]) .where(conditions) .where(job: job.id, main: false) .or( - JobSkill.method("#{locale}_search").call(search_params[:query]) + JobSkill.joins(:job) + .method("#{locale}_search").call(search_params[:query]) .where(conditions) .where(sub: true) .where.not(job: job.id) ) + .or( + JobSkill.joins(:job) + .method("#{locale}_search").call(search_params[:query]) + .where(conditions) + .where(job: { base_job: job.base_job.id }, emp: true) + .where.not(job: job.id) + ) else JobSkill.all + .joins(:job) .where(conditions) .where(job: job.id, main: false) .or( @@ -165,6 +175,13 @@ module Api .where(job: job.base_job.id, base: true) .where.not(job: job.id) ) + .or( + JobSkill.all + .where(conditions) + .joins(:job) + .where(job: { base_job: job.base_job.id }, emp: true) + .where.not(job: job.id) + ) end count = skills.length From 31e05179e2f0dfb74754dcffd0aa3dfc84252476 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 16 Mar 2023 08:35:28 -0700 Subject: [PATCH 6/6] Add granblue_id to WeaponKeys (#77) * Small Rails 7 configuration changes (#72) * Remove log call * Show EMP skills for Row 5 classes Row 4 EMP skills were not showing up, so you couldn't set Rage IV on Viking, for example * Allow adding EMP skills from prior rows to team We let you search but didn't fix the server-side validation check for skills * Add `granblue_id` column to WeaponKeys table This should have a `NOT NULL` constraint, but due to existing data it is nullable until we can update all environments with values. * Add granblue_id to WeaponKeyBlueprint * Migrate database --- app/blueprints/api/v1/weapon_key_blueprint.rb | 2 +- ...15095656_add_granblue_id_to_weapon_keys.rb | 6 ++ db/schema.rb | 82 +++++++++++++++++-- 3 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20230315095656_add_granblue_id_to_weapon_keys.rb diff --git a/app/blueprints/api/v1/weapon_key_blueprint.rb b/app/blueprints/api/v1/weapon_key_blueprint.rb index e83d8ea..0604f3e 100644 --- a/app/blueprints/api/v1/weapon_key_blueprint.rb +++ b/app/blueprints/api/v1/weapon_key_blueprint.rb @@ -10,7 +10,7 @@ module Api } end - fields :slug, :series, :slot, :group, :order + fields :granblue_id, :slug, :series, :slot, :group, :order end end end diff --git a/db/migrate/20230315095656_add_granblue_id_to_weapon_keys.rb b/db/migrate/20230315095656_add_granblue_id_to_weapon_keys.rb new file mode 100644 index 0000000..31830b7 --- /dev/null +++ b/db/migrate/20230315095656_add_granblue_id_to_weapon_keys.rb @@ -0,0 +1,6 @@ +class AddGranblueIdToWeaponKeys < ActiveRecord::Migration[7.0] + def change + # This needs to be NOT NULL, but initially it will be nullable until we migrate data + add_column :weapon_keys, :granblue_id, :integer, unique: true, null: true + end +end diff --git a/db/schema.rb b/db/schema.rb index bd7970e..e354921 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,19 +10,62 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_01_31_084343) do +ActiveRecord::Schema[7.0].define(version: 2023_03_15_095656) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gin" enable_extension "pg_trgm" enable_extension "pgcrypto" enable_extension "plpgsql" - enable_extension "timescaledb" create_table "app_updates", primary_key: "updated_at", id: :datetime, force: :cascade do |t| t.string "update_type", null: false t.string "version" end + create_table "character_charge_attacks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "character_id" + t.string "name_en", null: false + t.string "name_jp", null: false + t.string "description_en", null: false + t.string "description_jp", null: false + t.integer "order", null: false + t.string "form" + t.uuid "effects", array: true + t.index ["character_id"], name: "index_character_charge_attacks_on_character_id" + end + + create_table "character_skills", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "character_id" + t.string "name_en", null: false + t.string "name_jp", null: false + t.string "description_en", null: false + t.string "description_jp", null: false + t.integer "type", null: false + t.integer "position", null: false + t.string "form" + t.integer "cooldown", default: 0, null: false + t.integer "lockout", default: 0, null: false + t.integer "duration", array: true + t.boolean "recast", default: false, null: false + t.integer "obtained_at", default: 1, null: false + t.uuid "effects", array: true + t.index ["character_id"], name: "index_character_skills_on_character_id" + end + + create_table "character_support_skills", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "character_id" + t.string "name_en", null: false + t.string "name_jp", null: false + t.string "description_en", null: false + t.string "description_jp", null: false + t.integer "position", null: false + t.integer "obtained_at" + t.boolean "emp", default: false, null: false + t.boolean "transcendence", default: false, null: false + t.uuid "effects", array: true + t.index ["character_id"], name: "index_character_support_skills_on_character_id" + end + create_table "characters", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name_en" t.string "name_jp" @@ -50,10 +93,26 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_31_084343) do t.integer "max_hp_ulb" t.integer "max_atk_ulb" t.integer "character_id", default: [], null: false, array: true + t.string "nicknames_en", default: [], null: false, array: true + t.string "nicknames_jp", default: [], null: false, array: true t.index ["name_en"], name: "index_characters_on_name_en", opclass: :gin_trgm_ops, using: :gin end - create_table "data_migrations", primary_key: "version", id: :string, force: :cascade do |t| + create_table "effects", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.string "name_en", null: false + t.string "name_jp", null: false + t.string "description_en", null: false + t.string "description_jp", null: false + t.integer "accuracy_value" + t.string "accuracy_suffix" + t.string "accuracy_comparator" + t.jsonb "strength", array: true + t.integer "healing_cap" + t.boolean "duration_indefinite", default: false, null: false + t.integer "duration_value" + t.string "duration_unit" + t.string "notes_en" + t.string "notes_jp" end create_table "favorites", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| @@ -80,6 +139,10 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_31_084343) do t.jsonb "ring4", default: {"modifier"=>nil, "strength"=>nil}, null: false t.jsonb "earring", default: {"modifier"=>nil, "strength"=>nil}, null: false t.jsonb "awakening", default: {"type"=>1, "level"=>1}, null: false + t.boolean "skill0_enabled", default: true, null: false + t.boolean "skill1_enabled", default: true, null: false + t.boolean "skill2_enabled", default: true, null: false + t.boolean "skill3_enabled", default: true, 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 @@ -94,6 +157,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_31_084343) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "transcendence_step", default: 0, null: false + t.boolean "quick_summon", default: false, null: false t.index ["party_id"], name: "index_grid_summons_on_party_id" t.index ["summon_id"], name: "index_grid_summons_on_summon_id" end @@ -154,12 +218,13 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_31_084343) do t.integer "proficiency1" t.integer "proficiency2" t.string "row" - t.boolean "ml", default: false + t.boolean "master_level", default: false, null: false t.integer "order" t.uuid "base_job_id" t.string "granblue_id" t.boolean "accessory", default: false t.integer "accessory_type", default: 0 + t.boolean "ultimate_mastery", default: false, null: false t.index ["base_job_id"], name: "index_jobs_on_base_job_id" end @@ -213,7 +278,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_31_084343) do t.integer "element" t.integer "weapons_count" t.uuid "job_id" - t.integer "ml" + t.integer "master_level" t.uuid "skill1_id" t.uuid "skill2_id" t.uuid "skill3_id" @@ -231,6 +296,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_31_084343) do t.integer "summons_count" t.string "edit_key" t.uuid "local_id" + t.integer "ultimate_mastery" t.index ["accessory_id"], name: "index_parties_on_accessory_id" t.index ["job_id"], name: "index_parties_on_job_id" t.index ["skill0_id"], name: "index_parties_on_skill0_id" @@ -273,6 +339,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_31_084343) do t.boolean "xlb", default: false, null: false t.integer "max_atk_xlb" t.integer "max_hp_xlb" + t.string "nicknames_en", default: [], null: false, array: true + t.string "nicknames_jp", default: [], null: false, array: true t.index ["name_en"], name: "index_summons_on_name_en", opclass: :gin_trgm_ops, using: :gin end @@ -299,6 +367,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_31_084343) do t.integer "group" t.integer "order" t.string "slug" + t.integer "granblue_id" end create_table "weapons", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| @@ -326,6 +395,9 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_31_084343) do t.boolean "awakening", default: true, null: false t.boolean "limit", default: false, null: false t.boolean "ax", default: false, null: false + t.integer "awakening_types", default: [], array: true + t.string "nicknames_en", default: [], null: false, array: true + t.string "nicknames_jp", default: [], null: false, array: true t.index ["name_en"], name: "index_weapons_on_name_en", opclass: :gin_trgm_ops, using: :gin end