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 1 commit
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
12 changes: 12 additions & 0 deletions Frontend/src/api/registration/get/get_waiting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import backendFetch from '../../helper/backend_fetch'
import { components } from '../../schema'

export async function getWaitingCompetitors(
competitionId: string
): Promise<components['schemas']['registration'][]> {
return backendFetch(`/registrations/${competitionId}/waiting`, 'GET', {
needsAuthentication: false,
}) as Promise<
components['schemas']['registration'][]
>
}
4 changes: 2 additions & 2 deletions Frontend/src/pages/registrations/index.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react'
import RegistrationList from './components/RegistrationList'
import styles from './index.module.scss'
import { Header } from "semantic-ui-react";

export default function Registrations() {
return (
<div>
<div className={styles.listHeader}>Competitors:</div>
<Header>Competitors:</Header>
<RegistrationList />
</div>
)
Expand Down
39 changes: 39 additions & 0 deletions Frontend/src/pages/waiting/components/WaitingList.jsx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on using "waitlist" everywhere? I think that's quite standard, at least in North America. It also makes all the file and variable names a bit shorter and consistent (sometimes it's waiting, sometimes waiting_list, etc. at the moment).

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { useQuery } from '@tanstack/react-query'
import { useContext } from 'react'
import { Table } from 'semantic-ui-react'
import { CompetitionContext } from '../../../api/helper/context/competition_context'
import { getWaitingCompetitors } from '../../../api/registration/get/get_waiting'
import { setMessage } from '../../../ui/events/messages'
import LoadingMessage from '../../../ui/messages/loadingMessage'

export default function WaitingList() {
const { competitionInfo } = useContext(CompetitionContext)
const { isLoading, data: waiting } = useQuery({
queryKey: ['waiting', competitionInfo.id],
queryFn: () => getWaitingCompetitors(competitionInfo.id),
retry: false,
onError: (err) => {
setMessage(err.message, 'error')
},
})
return isLoading ? (
<LoadingMessage />
) : (
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Name</Table.HeaderCell>
<Table.HeaderCell>Position</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{waiting.map((w, i) => (
<Table.Row key={w.user_id}>
<Table.Cell>{w.user_id}</Table.Cell>
<Table.Cell>{i}</Table.Cell>
</Table.Row>
))}
</Table.Body>
</Table>
)
}
12 changes: 12 additions & 0 deletions Frontend/src/pages/waiting/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react'
import { Header } from 'semantic-ui-react'
import WaitingList from './components/WaitingList'

export default function Registrations() {
return (
<div>
<Header>Competitors:</Header>
<WaitingList />
</div>
)
}
26 changes: 25 additions & 1 deletion app/controllers/registration_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
require_relative '../helpers/error_codes'

class RegistrationController < ApplicationController
skip_before_action :validate_token, only: [:list]
skip_before_action :validate_token, only: [:list, :list_waiting]
# The order of the validations is important to not leak any non public info via the API
# That's why we should always validate a request first, before taking any other before action
# before_actions are triggered in the order they are defined
Expand Down Expand Up @@ -200,6 +200,30 @@ def list
status: :internal_server_error
end

def mine
my_registrations = Registration.where(user_id: @current_user).map {|x| {competition_id: x.competition_id, status: x.competing_status}}
render json: { registrations: my_registrations }
rescue StandardError => e
# Render an error response
puts e
Metrics.registration_dynamodb_errors_counter.increment
render json: { error: "Error getting registrations #{e}" },
status: :internal_server_error
end

def list_waiting
competition_id = list_params
registrations = get_registrations(competition_id)
waiting = registrations.filter_map { |r| { user_id: r['user_id'], competing: { event_ids: r.competing.event_ids } } if r.competing.registration_status == 'waiting_list' }
render json: waiting
rescue StandardError => e
# Render an error response
puts e
Metrics.registration_dynamodb_errors_counter.increment
render json: { error: "Error getting registrations #{e}" },
status: :internal_server_error
end

# To list Registrations in the admin view you need to be able to administer the competition
def validate_list_admin
@competition_id = list_params
Expand Down
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
get '/api/v1/register', to: 'registration#show'
post '/api/v1/register', to: 'registration#create'
patch '/api/v1/register', to: 'registration#update'
get '/api/v1/registrations/:competition_id/admin', to: 'registration#list_admin'
get '/api/v1/registrations/mine', to: 'registration#mine'
get '/api/v1/registrations/:competition_id', to: 'registration#list'
get '/api/v1/registrations/:competition_id/admin', to: 'registration#list_admin'
get '/api/v1/registrations/:competition_id/waiting', to: 'registration#list_waiting'
get '/api/v1/:competition_id/payment', to: 'registration#payment_ticket'
end