From 906c0c09ecc44c260789e40a3785bbee85f09d90 Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Tue, 12 Nov 2024 10:36:57 +0100 Subject: [PATCH 1/2] add internal waiting_list route for migration --- app/controllers/internal_controller.rb | 6 ++++++ config/routes.rb | 1 + 2 files changed, 7 insertions(+) diff --git a/app/controllers/internal_controller.rb b/app/controllers/internal_controller.rb index 1eb0488c..5642ca92 100644 --- a/app/controllers/internal_controller.rb +++ b/app/controllers/internal_controller.rb @@ -121,4 +121,10 @@ def history history = RegistrationHistory.find(attendee_id) render json: history end + + def waiting_list + competition_id = params.require(:competition_id) + waiting_list = WaitingList.find(competition_id) + render json: waiting_list.entries + end end diff --git a/config/routes.rb b/config/routes.rb index 8cf590d6..41561bd8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,6 +11,7 @@ get '/healthcheck', to: 'healthcheck#index' post '/api/internal/v1/update_payment', to: 'internal#update_payment_status' get '/api/internal/v1/:competition_id/registrations', to: 'internal#list_registrations' + get '/api/internal/v1/:competition_id/waiting_list', to: 'internal#waiting_list' post '/api/internal/v1/:competition_id/add', to: 'internal#create' get '/api/internal/v1/:attendee_id', to: 'internal#show_registration' get '/api/internal/v1/:attendee_id/history', to: 'internal#history' From 6e301911a9e98ddf21fb5a5829b316e881453e05 Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Tue, 12 Nov 2024 10:43:18 +0100 Subject: [PATCH 2/2] don't break if the competition has no waiting list --- app/controllers/internal_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/internal_controller.rb b/app/controllers/internal_controller.rb index 5642ca92..34b634df 100644 --- a/app/controllers/internal_controller.rb +++ b/app/controllers/internal_controller.rb @@ -124,7 +124,11 @@ def history def waiting_list competition_id = params.require(:competition_id) - waiting_list = WaitingList.find(competition_id) - render json: waiting_list.entries + begin + waiting_list = WaitingList.find(competition_id) + render json: waiting_list.entries + rescue Dynamoid::Errors::RecordNotFound + render json: [] + end end end