diff --git a/.env.assets.production b/.env.assets.production index 929ae62dbf..776837d444 100644 --- a/.env.assets.production +++ b/.env.assets.production @@ -1,3 +1,4 @@ WCA_REGISTRATIONS_URL=https://registration.worldcubeassociation.org -WCA_REGISTRATIONS_POLL_URL=https://1rq8d7dif3.execute-api.us-west-2.amazonaws.com/v1/prod +V2_REGISTRATIONS_POLL_URL=https://1rq8d7dif3.execute-api.us-west-2.amazonaws.com/v1/prod +V3_REGISTRATIONS_POLL_URL=https://t7ni46t9jd.execute-api.us-west-2.amazonaws.com/v1/prod ROOT_URL=https://www.worldcubeassociation.org diff --git a/.env.assets.staging b/.env.assets.staging index b92dd69d7d..e4f6aa6770 100644 --- a/.env.assets.staging +++ b/.env.assets.staging @@ -1,3 +1,4 @@ WCA_REGISTRATIONS_URL=https://staging.registration.worldcubeassociation.org -WCA_REGISTRATIONS_POLL_URL=https://1rq8d7dif3.execute-api.us-west-2.amazonaws.com/v1/staging +V2_REGISTRATIONS_POLL_URL=https://1rq8d7dif3.execute-api.us-west-2.amazonaws.com/v1/staging +V3_REGISTRATIONS_POLL_URL=https://t7ni46t9jd.execute-api.us-west-2.amazonaws.com/v1/staging ROOT_URL=https://staging.worldcubeassociation.org diff --git a/app/webpacker/components/RegistrationsV2/Register/Processing.jsx b/app/webpacker/components/RegistrationsV2/Register/Processing.jsx index 84ae47948b..b6144b128a 100644 --- a/app/webpacker/components/RegistrationsV2/Register/Processing.jsx +++ b/app/webpacker/components/RegistrationsV2/Register/Processing.jsx @@ -11,7 +11,7 @@ export default function Processing({ competitionInfo, user, onProcessingComplete const { data } = useQuery({ queryKey: ['registration-status-polling', user.id, competitionInfo.id], - queryFn: async () => pollRegistrations(user.id, competitionInfo.id), + queryFn: async () => pollRegistrations(user.id, competitionInfo), refetchInterval: REFETCH_INTERVAL, onSuccess: () => { setPollCounter(pollCounter + 1); diff --git a/app/webpacker/components/RegistrationsV2/api/mocks/polling_mock.js b/app/webpacker/components/RegistrationsV2/api/mocks/polling_mock.js index a1ac85d2b5..dc4bbd5cb0 100644 --- a/app/webpacker/components/RegistrationsV2/api/mocks/polling_mock.js +++ b/app/webpacker/components/RegistrationsV2/api/mocks/polling_mock.js @@ -2,10 +2,10 @@ import { getSingleRegistration } from '../registration/get/get_registrations'; export default async function pollingMock( userId, - competitionId, + competition, ) { // Now that we are doing more things on Registration create we have to poll ourselves - const registration = await getSingleRegistration(userId, competitionId); + const registration = await getSingleRegistration(userId, competition); return { status: { competing: registration?.competing.registration_status ?? 'processing', diff --git a/app/webpacker/components/RegistrationsV2/api/registration/get/poll_registrations.js b/app/webpacker/components/RegistrationsV2/api/registration/get/poll_registrations.js index edbe2ff01d..963582d341 100644 --- a/app/webpacker/components/RegistrationsV2/api/registration/get/poll_registrations.js +++ b/app/webpacker/components/RegistrationsV2/api/registration/get/poll_registrations.js @@ -4,11 +4,12 @@ import { fetchJsonOrError } from '../../../../../lib/requests/fetchWithAuthentic export default async function pollRegistrations( userId, - competitionId, + competition, ) { if (process.env.NODE_ENV === 'production') { - const { data } = await fetchJsonOrError(pollingRoute(userId, competitionId)); + const route = pollingRoute[competition.registration_version](userId, competition.id) + const { data } = await fetchJsonOrError(route); return data; } - return pollingMock(userId, competitionId); + return pollingMock(userId, competition); } diff --git a/app/webpacker/lib/requests/routes.js.erb b/app/webpacker/lib/requests/routes.js.erb index ab99963e55..aa261a7b5b 100644 --- a/app/webpacker/lib/requests/routes.js.erb +++ b/app/webpacker/lib/requests/routes.js.erb @@ -236,7 +236,10 @@ export const panelUrls = { export const userPreferencesRoute = `<%= CGI.unescape(Rails.application.routes.url_helpers.profile_edit_path)%>?section=preferences`; -export const pollingRoute = (userId, competitionId) => `<%= CGI.unescape(EnvConfig.WCA_REGISTRATIONS_POLL_URL)%>?attendee_id=${competitionId}-${userId}`; +export const pollingRoute = (userId, competitionId) => ({ + v2: `<%= CGI.unescape(EnvConfig.V2_REGISTRATIONS_POLL_URL)%>?attendee_id=${competitionId}-${userId}`, + v3: `<%= CGI.unescape(EnvConfig.V3_REGISTRATIONS_POLL_URL)%>?competition_id=${competitionId}&user_id=${userId}` +}); export const wcaRegistrationUrl = `<%= CGI.unescape(EnvConfig.WCA_REGISTRATIONS_URL)%>`; diff --git a/env_config.rb b/env_config.rb index 6c0ffe3b1c..3a24df9a37 100644 --- a/env_config.rb +++ b/env_config.rb @@ -30,7 +30,6 @@ mandatory :VAULT_AWS_REGION, :string mandatory :TASK_ROLE, :string mandatory :WCA_REGISTRATIONS_URL, :string - mandatory :WCA_REGISTRATIONS_POLL_URL, :string mandatory :ASSET_HOST, :string mandatory :CDN_ASSETS_DISTRIBUTION_ID, :string else @@ -61,6 +60,11 @@ mandatory :WCA_REGISTRATIONS_BACKEND_URL, :string end + if is_compiling_assets + mandatory :V2_REGISTRATIONS_POLL_URL, :string + mandatory :V3_REGISTRATIONS_POLL_URL, :string + end + if Rails.env.test? optional :DISABLE_WEBMOCK, :bool, false optional :DISABLE_NET_CONNECT_IN_TESTS, :bool, false