From d587ceeeec1e0083967bfcb501808492231d4696 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 5 Feb 2023 00:56:27 -0800 Subject: [PATCH 1/5] 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/5] 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/5] 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/5] 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/5] 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