Skip to content
This repository was archived by the owner on Jan 3, 2025. It is now read-only.

Add Public Waiting List Tab #295

Merged
merged 34 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2247165
Waiting List Frontend
FinnIckler Oct 30, 2023
b509b0d
Merge branch 'main' into feature/public-waiting-list
FinnIckler Nov 28, 2023
6b4b04c
implement waiting list management
FinnIckler Nov 28, 2023
52b8ec6
run rubocop
FinnIckler Nov 28, 2023
5b7214e
fix eslint
FinnIckler Nov 28, 2023
8085fa2
correctly show the number of waiting competitors
FinnIckler Nov 28, 2023
591beb9
check length of waiting too
FinnIckler Nov 29, 2023
63e5a30
don't force organizers to update the waitlist everytime someone is ap…
FinnIckler Nov 29, 2023
23c4e0e
adding tests for waiting list
dunkOnIT Dec 3, 2023
6e84a32
Merge branch 'main' into feature/public-waiting-list
dunkOnIT Dec 3, 2023
4a15623
waiting list tests passing
dunkOnIT Dec 4, 2023
55d0642
refactored waiting list functions
dunkOnIT Dec 4, 2023
aef04b2
added cache invalidations
dunkOnIT Dec 5, 2023
b148ee6
corrected typing of test values and updated type acceptance tests
dunkOnIT Dec 7, 2023
3a45ed1
added tests for waiting list position outside of min/max boundary
dunkOnIT Dec 7, 2023
df81d68
re-enabled cache
dunkOnIT Dec 11, 2023
2121616
caching tests
dunkOnIT Dec 12, 2023
82e4e14
Fixed caches not updating and introduced a method in lib
FinnIckler Dec 12, 2023
5050fed
corrected cache behaviour
dunkOnIT Dec 13, 2023
2108e2d
removed puts statements
dunkOnIT Dec 13, 2023
32765dd
removed get/set and refactored to use minmax
dunkOnIT Dec 13, 2023
4ec7744
removed caching-test config files
dunkOnIT Dec 13, 2023
d0472d7
remove cache_test fro mgemfile
dunkOnIT Dec 13, 2023
c8cc997
refactored list_waiting to use get_by_status
dunkOnIT Dec 13, 2023
7139c59
skipping jwt validation on list_waiting temproarily
dunkOnIT Dec 13, 2023
dc967ca
removed caching of waiting list
dunkOnIT Dec 13, 2023
4d84bca
removed commented code and unnecessary docs
dunkOnIT Dec 13, 2023
f10c549
fix issue with worker not loading lane
FinnIckler Dec 13, 2023
b1bdeb8
fix issue with multiple updates not waiting before the other completes
FinnIckler Dec 13, 2023
880622d
Merge branch 'main' into feature/public-waiting-list
FinnIckler Dec 13, 2023
337c5ad
fix typo
FinnIckler Dec 13, 2023
52a215b
Add Segment for Waiting List
FinnIckler Dec 13, 2023
298f2f3
run eslint
FinnIckler Dec 13, 2023
304e809
added redis to backend-test compose file
dunkOnIT Dec 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 42 additions & 17 deletions Frontend/src/api/registration/get/get_registrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@ const { GET } = createClient<paths>({
baseUrl: process.env.API_URL.slice(0, -7),
})

async function addUserInfo(
registrations:
| components['schemas']['registration'][]
| components['schemas']['registrationAdmin'][]
): Promise<
| components['schemas']['registration'][]
| components['schemas']['registrationAdmin'][]
> {
if (registrations.length > 0) {
const userInfos = await getCompetitorsInfo(
registrations.map((d) => d.user_id)
)
return registrations.map((registration) => ({
...registration,
user: userInfos.users.find(
(user) => user.id === Number(registration.user_id)
),
}))
}
return []
}

export async function getConfirmedRegistrations(
competitionID: string
): Promise<components['schemas']['registration'][]> {
Expand All @@ -25,16 +47,7 @@ export async function getConfirmedRegistrations(
if (!response.ok) {
throw new BackendError(500, response.status)
}
if (data!.length > 0) {
const userInfos = await getCompetitorsInfo(data!.map((d) => d.user_id))
return data!.map((registration) => ({
...registration,
user: userInfos.users.find(
(user) => user.id === Number(registration.user_id)
),
}))
}
return []
return addUserInfo(data!)
}

export async function getAllRegistrations(
Expand All @@ -55,13 +68,9 @@ export async function getAllRegistrations(
}
throw new BackendError(error.error, response.status)
}
const userInfos = await getCompetitorsInfo(data!.map((d) => d.user_id))
return data!.map((registration) => ({
...registration,
user: userInfos.users.find(
(user) => user.id === Number(registration.user_id)
),
}))
return (await addUserInfo(
data!
)) as components['schemas']['registrationAdmin'][]
}

export async function getSingleRegistration(
Expand All @@ -74,3 +83,19 @@ export async function getSingleRegistration(
{ needsAuthentication: true }
) as Promise<{ registration: components['schemas']['registrationAdmin'] }>
}

export async function getWaitingCompetitors(
competitionId: string
): Promise<components['schemas']['registrationAdmin'][]> {
const registrations = (await backendFetch(
`/registrations/${competitionId}/waiting`,
'GET',
{
needsAuthentication: false,
}
)) as components['schemas']['registrationAdmin'][]

return (await addUserInfo(
registrations
)) as components['schemas']['registrationAdmin'][]
}
227 changes: 114 additions & 113 deletions Frontend/src/api/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,195 +3,196 @@
* Do not make direct changes to the file.
*/


export interface paths {
"/api/v1/registrations/{competition_id}": {
'/api/v1/registrations/{competition_id}': {
/** Public: list registrations for a given competition_id */
get: {
parameters: {
path: {
competition_id: string;
};
};
competition_id: string
}
}
responses: {
/** @description -> PASSING comp service down but registrations exist */
200: {
content: {
"application/json": components["schemas"]["registration"][];
};
};
};
};
};
"/api/v1/registrations/{competition_id}/admin": {
'application/json': components['schemas']['registration'][]
}
}
}
}
}
'/api/v1/registrations/{competition_id}/admin': {
/** Public: list registrations for a given competition_id */
get: {
parameters: {
path: {
competition_id: string;
};
};
competition_id: string
}
}
responses: {
/** @description -> PASSING organizer has access to comp 2 */
200: {
content: {
"application/json": components["schemas"]["registrationAdmin"][];
};
};
'application/json': components['schemas']['registrationAdmin'][]
}
}
/** @description -> PASSING organizer cannot access registrations for comps they arent organizing - multi comp auth */
401: {
content: {
"application/json": components["schemas"]["error_response"];
};
};
};
};
};
"/api/v1/register": {
'application/json': components['schemas']['error_response']
}
}
}
}
}
'/api/v1/register': {
/** Add an attendee registration */
post: {
requestBody: {
content: {
"application/json": components["schemas"]["submitRegistrationBody"];
};
};
'application/json': components['schemas']['submitRegistrationBody']
}
}
responses: {
/** @description -> PASSING competitor submits basic registration */
202: {
content: {
"application/json": components["schemas"]["success_response"];
};
};
'application/json': components['schemas']['success_response']
}
}
/** @description -> PASSING empty payload provided */
400: {
content: {
"application/json": components["schemas"]["error_response"];
};
};
'application/json': components['schemas']['error_response']
}
}
/** @description -> PASSING user impersonation (no admin permission, JWT token user_id does not match registration user_id) */
401: {
content: {
"application/json": components["schemas"]["error_response"];
};
};
'application/json': components['schemas']['error_response']
}
}
/** @description -> PASSING user cant register while registration is closed */
403: {
content: {
"application/json": components["schemas"]["error_response"];
};
};
'application/json': components['schemas']['error_response']
}
}
/** @description -> PASSING competition does not exist */
404: {
content: {
"application/json": components["schemas"]["error_response"];
};
};
'application/json': components['schemas']['error_response']
}
}
/** @description PASSING user registration exceeds guest limit */
422: {
content: {
"application/json": components["schemas"]["error_response"];
};
};
};
};
'application/json': components['schemas']['error_response']
}
}
}
}
/** update or cancel an attendee registration */
patch: {
requestBody: {
content: {
"application/json": components["schemas"]["updateRegistrationBody"];
};
};
'application/json': components['schemas']['updateRegistrationBody']
}
}
responses: {
/** @description PASSING user changes comment */
200: {
content: {
"application/json": {
status?: string;
registration?: components["schemas"]["registrationAdmin"];
};
};
};
'application/json': {
status?: string
registration?: components['schemas']['registrationAdmin']
}
}
}
/** @description PASSING user requests invalid status change to their own reg */
401: {
content: {
"application/json": components["schemas"]["error_response"];
};
};
'application/json': components['schemas']['error_response']
}
}
/** @description PASSING user changes events / other stuff past deadline */
403: {
content: {
"application/json": components["schemas"]["error_response"];
};
};
'application/json': components['schemas']['error_response']
}
}
/** @description PASSING user does not include required comment */
422: {
content: {
"application/json": components["schemas"]["error_response"];
};
};
};
};
};
'application/json': components['schemas']['error_response']
}
}
}
}
}
}

export type webhooks = Record<string, never>;
export type webhooks = Record<string, never>

export interface components {
schemas: {
error_response: {
error: number;
};
error: number
}
success_response: {
status: string;
message: string;
};
status: string
message: string
}
registration: {
user_id: string;
user_id: string
competing: {
event_ids: EventId[];
};
};
event_ids: EventId[]
}
}
registrationAdmin: {
user_id: string;
user_id: string
competing: {
event_ids: EventId[];
registered_on: string;
registration_status: string;
comment?: string | null;
admin_comment?: string | null;
};
guests?: number | null;
};
event_ids: EventId[]
registered_on: string
registration_status: string
comment?: string | null
admin_comment?: string | null
waiting_list_position?: number | null
}
guests?: number | null
}
submitRegistrationBody: {
user_id: string;
competition_id: string;
user_id: string
competition_id: string
competing: {
event_ids?: EventId[];
comment?: string;
guests?: number;
};
};
event_ids?: EventId[]
comment?: string
guests?: number
}
}
updateRegistrationBody: {
user_id: string;
competition_id: string;
user_id: string
competition_id: string
competing?: {
event_ids?: EventId[];
status?: string;
comment?: string;
admin_comment?: string;
};
guests?: number;
};
};
responses: never;
parameters: never;
requestBodies: never;
headers: never;
pathItems: never;
event_ids?: EventId[]
status?: string
comment?: string
admin_comment?: string
waiting_list_position?: number
}
guests?: number
}
}
responses: never
parameters: never
requestBodies: never
headers: never
pathItems: never
}

export type $defs = Record<string, never>;
export type $defs = Record<string, never>

export type external = Record<string, never>;
export type external = Record<string, never>

export type operations = Record<string, never>;
export type operations = Record<string, never>
Loading