From 0c65d4d167c9f107263546280c5210023e4c453f Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Wed, 24 Jul 2024 22:52:28 +0200 Subject: [PATCH] fix API contract --- app/controllers/registrations_controller.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 0827a83cb9..209fd54857 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -164,7 +164,7 @@ def do_import delete_params = [] registrations.filter { |r| r.accepted? }.each do |registration| unless emails.include?(registration.user.email) - delete_params << { attendee_id: registration.attendee_id, competing_status: "deleted", acting_id: current_user.id, acting_type: "user" } + delete_params << { attendee_id: registration.attendee_id, user_id: registration.user.id, competing_status: "deleted", actor_id: current_user.id, actor_type: "user" } end end registration_rows.each do |registration_row| @@ -174,20 +174,20 @@ def do_import events = competition.competition_events.each_with_object([]) do |competition_event, signed_up_events| value = registration_row[competition_event.event_id.to_sym] if value == "1" - signed_up_events >> competition_event.id + signed_up_events << competition_event.event_id elsif value != "0" raise I18n.t("registrations.import.errors.invalid_event_column", value: value, column: competition_event.event_id) end end if registration.nil? - create_params << { attendee_id: "#{competition.id}-#{user.id}", competing_status: "accepted", acting_id: current_user.id, acting_type: "user", event_ids: events } + create_params << { attendee_id: "#{competition.id}-#{user.id}", user_id: user.id, competing_status: "accepted", actor_id: current_user.id, actor_type: "user", event_ids: events } else - update_params << { attendee_id: registration.attendee_id, competing_status: "accepted", acting_id: current_user.id, acting_type: "user", event_ids: events } + update_params << { attendee_id: registration.attendee_id, user_id: user.id, competing_status: "accepted", actor_id: current_user.id, actor_type: "user", event_ids: events } end end import_response = Microservices::Registrations.import_registrations(competition.id, { create: create_params, update: update_params, delete: delete_params }) - if import_response.errors.any? - raise import_response.errors.join(', ') + unless import_response[:errors].nil? + raise import_response[:errors].join(', ') end else ActiveRecord::Base.transaction do @@ -225,6 +225,7 @@ def do_import redirect_to competition_registrations_import_url(competition) rescue StandardError => e flash[:danger] = e.to_s + puts e.backtrace redirect_to competition_registrations_import_url(competition) end