Skip to content

Commit

Permalink
PsychSheet default sort fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pranav-027 committed Jan 15, 2025
1 parent 1c2629d commit 42a4b58
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 24 deletions.
7 changes: 6 additions & 1 deletion app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,22 @@ def self.dump_static
)
end

def blindfolded_event?
['333bf', '444bf', '555bf', '333mbf', '333mbo'].include?(self.id)
end

alias_method :can_change_time_limit, :can_change_time_limit?
alias_method :can_have_cutoff, :can_have_cutoff?
alias_method :is_timed_event, :timed_event?
alias_method :is_fewest_moves, :fewest_moves?
alias_method :is_multiple_blindfolded, :multiple_blindfolded?
alias_method :is_official, :official?
alias_method :is_blindfolded, :blindfolded_event?

DEFAULT_SERIALIZE_OPTIONS = {
only: ["id"],
methods: ["name", "can_change_time_limit", "can_have_cutoff", "is_timed_event",
"is_fewest_moves", "is_multiple_blindfolded", "is_official", "format_ids"],
"is_fewest_moves", "is_multiple_blindfolded", "is_official", "format_ids","is_blindfolded"],
}.freeze

def serializable_hash(options = nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { formatAttemptResult } from '../../../lib/wca-live/attempts';
import I18n from '../../../lib/i18n';
import { countries } from '../../../lib/wca-data.js.erb';
import { EventSelector } from '../../wca/EventSelector';
import { events } from '../../../lib/wca-data.js.erb';

const sortReducer = createSortReducer(['name', 'country', 'total']);

Expand All @@ -39,11 +40,15 @@ export default function RegistrationList({ competitionInfo }) {
const changeSortColumn = (name) => sortDispatch({ type: 'CHANGE_SORT', sortColumn: name });

const [psychSheetEvent, setPsychSheetEvent] = useState();
const [psychSheetSortBy, setPsychSheetSortBy] = useState('single');
const [psychSheetSortBy, setPsychSheetSortBy] = useState();
const isPsychSheet = psychSheetEvent !== undefined
const isAllCompetitors = !isPsychSheet
const handleEventSelection = ({ type, eventId }) => {
setPsychSheetEvent(type === 'toggle_event' ? eventId : undefined);
if (type === 'toggle_event' ) {
const sortBy = events.byId[eventId].isBlindfolded? 'single' : 'average';
setPsychSheetSortBy(sortBy);
}
};

const { isLoading: isLoadingPsychSheet, data: psychSheet } = useQuery({
Expand Down
65 changes: 43 additions & 22 deletions lib/static_data/events.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"is_official": true,
"format_ids": [
"a"
]
],
"is_blindfolded": false
},
{
"id": "222",
Expand All @@ -27,7 +28,8 @@
"is_official": true,
"format_ids": [
"a"
]
],
"is_blindfolded": false
},
{
"id": "444",
Expand All @@ -42,7 +44,8 @@
"is_official": true,
"format_ids": [
"a"
]
],
"is_blindfolded": false
},
{
"id": "555",
Expand All @@ -57,7 +60,8 @@
"is_official": true,
"format_ids": [
"a"
]
],
"is_blindfolded": false
},
{
"id": "666",
Expand All @@ -72,7 +76,8 @@
"is_official": true,
"format_ids": [
"m"
]
],
"is_blindfolded": false
},
{
"id": "777",
Expand All @@ -87,7 +92,8 @@
"is_official": true,
"format_ids": [
"m"
]
],
"is_blindfolded": false
},
{
"id": "333bf",
Expand All @@ -102,7 +108,8 @@
"is_official": true,
"format_ids": [
"3"
]
],
"is_blindfolded": true
},
{
"id": "333fm",
Expand All @@ -119,7 +126,8 @@
"m",
"2",
"1"
]
],
"is_blindfolded": false
},
{
"id": "333oh",
Expand All @@ -134,7 +142,8 @@
"is_official": true,
"format_ids": [
"a"
]
],
"is_blindfolded": false
},
{
"id": "clock",
Expand All @@ -149,7 +158,8 @@
"is_official": true,
"format_ids": [
"a"
]
],
"is_blindfolded": false
},
{
"id": "minx",
Expand All @@ -164,7 +174,8 @@
"is_official": true,
"format_ids": [
"a"
]
],
"is_blindfolded": false
},
{
"id": "pyram",
Expand All @@ -179,7 +190,8 @@
"is_official": true,
"format_ids": [
"a"
]
],
"is_blindfolded": false
},
{
"id": "skewb",
Expand All @@ -194,7 +206,8 @@
"is_official": true,
"format_ids": [
"a"
]
],
"is_blindfolded": false
},
{
"id": "sq1",
Expand All @@ -209,7 +222,8 @@
"is_official": true,
"format_ids": [
"a"
]
],
"is_blindfolded": false
},
{
"id": "444bf",
Expand All @@ -224,7 +238,8 @@
"is_official": true,
"format_ids": [
"3"
]
],
"is_blindfolded": true
},
{
"id": "555bf",
Expand All @@ -239,7 +254,8 @@
"is_official": true,
"format_ids": [
"3"
]
],
"is_blindfolded": true
},
{
"id": "333mbf",
Expand All @@ -256,7 +272,8 @@
"1",
"2",
"3"
]
],
"is_blindfolded": true
},
{
"id": "333ft",
Expand All @@ -274,7 +291,8 @@
"3",
"2",
"1"
]
],
"is_blindfolded": false
},
{
"id": "magic",
Expand All @@ -289,7 +307,8 @@
"is_official": false,
"format_ids": [
"a"
]
],
"is_blindfolded": false
},
{
"id": "mmagic",
Expand All @@ -304,7 +323,8 @@
"is_official": false,
"format_ids": [
"a"
]
],
"is_blindfolded": false
},
{
"id": "333mbo",
Expand All @@ -321,6 +341,7 @@
"3",
"2",
"1"
]
],
"is_blindfolded": true
}
]
]

0 comments on commit 42a4b58

Please sign in to comment.