-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make psychsheets sort by average by default #10368
base: main
Are you sure you want to change the base?
Changes from all commits
b32efec
f066207
cbf5f4f
6542633
c4a3f93
76c3fe7
557c6ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,8 +94,10 @@ export default function RegistrationList({ competitionInfo }) { | |
const { sortColumn, sortDirection } = state; | ||
const changeSortColumn = (name) => dispatch({ type: 'CHANGE_SORT', sortColumn: name }); | ||
|
||
const blindFoldedEvents = ['333mbf', '333bf', '444bf', '555bf']; | ||
|
||
const [psychSheetEvent, setPsychSheetEvent] = useState(); | ||
const [psychSheetSortBy, setPsychSheetSortBy] = useState('single'); | ||
const psychSheetSortBy = useMemo(() => (blindFoldedEvents.includes(psychSheetEvent) ? 'single' : 'average'), [psychSheetEvent]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using my suggestion from above, you can compute this as |
||
|
||
const { isLoading: isLoadingPsychSheet, data: psychSheet } = useQuery({ | ||
queryKey: [ | ||
|
@@ -115,7 +117,6 @@ export default function RegistrationList({ competitionInfo }) { | |
|
||
const registrationsWithPsychsheet = useMemo(() => { | ||
if (psychSheet !== undefined) { | ||
setPsychSheetSortBy(psychSheet.sort_by); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this line being deleted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Otherwise, react throws an error that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, because you're changing to a (for example, this will break proper sorting on events like 333 which have genuine use-cases of using either single or average for sorting) |
||
return psychSheet.sorted_rankings.map((p) => { | ||
const registrationEntry = registrations.find((r) => p.user_id === r.user_id); | ||
return { ...p, ...registrationEntry }; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to hardcode this. We have events data available as
import { events } from 'lib/wca-data.js.erb'
(note you might need to change the relative path to the file)