Add accessory_id to Party and enable saving

Saves without validation right now
This commit is contained in:
Justin Edmund 2023-01-24 02:11:54 -08:00
parent ea7650a9bb
commit 7d142ada54
3 changed files with 16 additions and 3 deletions

View file

@ -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,

View file

@ -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

View file

@ -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"