diff --git a/app/controllers/api/v1/parties_controller.rb b/app/controllers/api/v1/parties_controller.rb index 81578b5..76c456f 100644 --- a/app/controllers/api/v1/parties_controller.rb +++ b/app/controllers/api/v1/parties_controller.rb @@ -44,6 +44,8 @@ module Api @party.attributes = party_params.except(:skill1_id, :skill2_id, :skill3_id) + # TODO: Validate accessory with job + return render json: PartyBlueprint.render(@party, view: :full, root: :party) if @party.save! render_validation_error_response(@party) @@ -64,7 +66,7 @@ module Api if new_party.save render json: PartyBlueprint.render(new_party, view: :full, root: :party, - meta: { remix: true }) + meta: { remix: true }) else render_validation_error_response(new_party) end @@ -124,7 +126,7 @@ module Api def build_conditions(params) unless params['recency'].blank? start_time = (DateTime.current - params['recency'].to_i.seconds) - .to_datetime.beginning_of_day + .to_datetime.beginning_of_day end {}.tap do |hash| @@ -176,6 +178,7 @@ module Api :description, :raid_id, :job_id, + :accessory_id, :skill0_id, :skill1_id, :skill2_id, diff --git a/db/migrate/20230124100823_add_accessory_id_to_party.rb b/db/migrate/20230124100823_add_accessory_id_to_party.rb new file mode 100644 index 0000000..2db0567 --- /dev/null +++ b/db/migrate/20230124100823_add_accessory_id_to_party.rb @@ -0,0 +1,7 @@ +class AddAccessoryIdToParty < ActiveRecord::Migration[7.0] + def change + change_table(:parties) do |t| + t.references :accessory, type: :uuid, foreign_key: { to_table: 'job_accessories' } + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 9cad249..20c1efc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_01_24_013326) do +ActiveRecord::Schema[7.0].define(version: 2023_01_24_100823) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gin" enable_extension "pg_trgm" @@ -215,6 +215,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_24_013326) do t.integer "chain_count" t.integer "turn_count" t.uuid "source_party_id" + t.uuid "accessory_id" + 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" t.index ["skill1_id"], name: "index_parties_on_skill1_id" @@ -324,6 +326,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_24_013326) do add_foreign_key "jobs", "jobs", column: "base_job_id" 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", "job_accessories", column: "accessory_id" add_foreign_key "parties", "job_skills", column: "skill0_id" add_foreign_key "parties", "job_skills", column: "skill1_id" add_foreign_key "parties", "job_skills", column: "skill2_id"