Skip to content

Options are not resilent to DB changes #299

@MichaelZhao21

Description

@MichaelZhao21

What is your question? Describe in detail.

Whenever the database schema is changed for options, it completely breaks the admin settings page. I would like to find a way to make this not happen and instead just update the database to include the field or have some default values. This is the offending function on the settings page:

async function getOptions() {
await fetchOptions();
// Calculate judging timer MM:SS
const timer = options.judging_timer;
if (timer) {
const minutes = Math.floor(timer / 60);
const seconds = timer % 60;
const timerStr = `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
setJudgingTimer(timerStr);
}
// Set min views
setMinViews(options.min_views);
// Set sync clock
setSyncClock(options.clock_sync);
// Set group options
setMultiGroup(options.multi_group);
setNumGroups(options.num_groups);
setGroupSizes(options.group_sizes.join(', '));
setSwitchingMode(options.switching_mode);
setAutoSwitchProp(options.auto_switch_prop);
setJudgeTracks(options.judge_tracks);
setTracks(options.tracks.join(', '));
setTrackViews(options.track_views.join(', '));
setGroupNames(options.group_names.join(', '));
setIgnoreTracks(options.ignore_tracks.join(', '));
setBlockReqs(options.block_reqs);
setMaxReqPerMin(options.max_req_per_min);
// Get active clock status
await fetchClock();
setRunning(clock.running);
setLoading(false);
}

Additional context

Ideally the invalid fields could be automatically updated to defaults in the database when the app loads, but this would require a big function that checks (though we already do the rank aggregation on load--see #285).

Another idea could be to just show default values on the settings page, but that may break other parts of the app that relies on that setting to be set.

Note that this ONLY is a problem when we have a database schema change. Hence, this issue isn't too significant rn.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A: BackendA task that concerns backend developmentA: FrontendA task that concerns frontend developmentquestionQuestion or open discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions