Feat: auto-reload
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Dorian Zedler 2022-07-29 09:45:12 +02:00
parent bd72659215
commit c730b182a9
Signed by: dorian
GPG key ID: 989DE36109AFA354
3 changed files with 14 additions and 12 deletions

View file

@ -75,8 +75,6 @@ function computeWinnerOfPair(pair: SpeedRoundPair, roundIndex: number) {
) )
return; return;
console.log('Conputing winner of round ', roundIndex);
pair.laneA.result = pair.laneA.participant.results[roundIndex]; pair.laneA.result = pair.laneA.participant.results[roundIndex];
pair.laneB.result = pair.laneB.participant.results[roundIndex]; pair.laneB.result = pair.laneB.participant.results[roundIndex];
@ -212,7 +210,6 @@ export function convertResultsToSpeedFlowchartResult(
// - 1, 4, 2, 3 for firstRoundNumber=4 // - 1, 4, 2, 3 for firstRoundNumber=4
// - 1, 2 for firstRoundNumber=2 // - 1, 2 for firstRoundNumber=2
// TODO: come up with a proper alogorithm maybe // TODO: come up with a proper alogorithm maybe
console.log('First round rank: ', firstRoundRank);
const ranksOfLaneAInOrder = [ const ranksOfLaneAInOrder = [
[1, 2], [1, 2],
[1, 4, 2, 3], [1, 4, 2, 3],
@ -234,12 +231,9 @@ export function convertResultsToSpeedFlowchartResult(
rounds.push(firstRound); rounds.push(firstRound);
console.log(firstRound);
// compute following rounds // compute following rounds
let roundIndex = roundIndices[1]; let roundIndex = roundIndices[1];
for (let roundRank = firstRoundRank; roundRank > 2; roundRank /= 2) { for (let roundRank = firstRoundRank; roundRank > 2; roundRank /= 2) {
console.log('Processing rank', roundRank);
rounds.push( rounds.push(
computeRoundFromPreviousRound( computeRoundFromPreviousRound(
roundIndex, roundIndex,

View file

@ -33,7 +33,6 @@ export default function CalendarPage() {
React.useEffect(() => { React.useEffect(() => {
api.getCompetitions('GER').then(result => { api.getCompetitions('GER').then(result => {
console.log(result.competitions.filter);
competitions.current = result.competitions.filter(competition => competitions.current = result.competitions.filter(competition =>
competition.discipline?.includes('speed'), competition.discipline?.includes('speed'),
); );

View file

@ -26,12 +26,22 @@ export default function SpeedFlowchartPage() {
useState<SpeedFlowchartResult>(); useState<SpeedFlowchartResult>();
useEffect(() => { useEffect(() => {
if (competitionId === undefined || categoryId === undefined) {
return;
}
setTitle(''); setTitle('');
setContainerMaxWidth(false); setContainerMaxWidth(false);
loadData();
const interval = setInterval(loadData, 2000);
return () => clearInterval(interval);
}, []);
const loadData = () => {
if (competitionId === undefined || categoryId === undefined) {
setLoading(false);
return;
}
api.getCompetitionResults(competitionId, categoryId).then(r => { api.getCompetitionResults(competitionId, categoryId).then(r => {
setTitle( setTitle(
`${r.comp_name} - ${ `${r.comp_name} - ${
@ -40,7 +50,6 @@ export default function SpeedFlowchartPage() {
); );
setLoading(false); setLoading(false);
console.log('loading false');
const flowchartResult = convertResultsToSpeedFlowchartResult(r); const flowchartResult = convertResultsToSpeedFlowchartResult(r);
const l = flowchartResult.rounds.length; const l = flowchartResult.rounds.length;
@ -56,7 +65,7 @@ export default function SpeedFlowchartPage() {
flowchartResult.rounds.pop(); flowchartResult.rounds.pop();
setFlowchartResult(flowchartResult); setFlowchartResult(flowchartResult);
}); });
}, []); };
return ( return (
<> <>