Skip to content

Commit

Permalink
add V3 Polling Url
Browse files Browse the repository at this point in the history
  • Loading branch information
FinnIckler committed Oct 26, 2024
1 parent 0d6d6a2 commit 368efa6
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .env.assets.production
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion .env.assets.staging
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
5 changes: 4 additions & 1 deletion app/webpacker/lib/requests/routes.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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)%>`;

Expand Down
6 changes: 5 additions & 1 deletion env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 368efa6

Please sign in to comment.