Skip to content

Commit

Permalink
Integration
Browse files Browse the repository at this point in the history
  • Loading branch information
tnrz155 committed Jan 12, 2025
1 parent 3b5f0d2 commit 46eb690
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions apps/backend/src/routers/api/admin/divisions/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ router.post(
const matchesStart = dayjs(settings.matchesStart);
settings.matchesStart = dayjs(event.startDate)
.set('minutes', matchesStart.get('minutes'))
.set('seconds', matchesStart.get('seconds'))
.set('hours', matchesStart.get('hours'))
.toDate();

const judgingStart = dayjs(settings.judgingStart);
settings.judgingStart = dayjs(event.startDate)
.set('minutes', judgingStart.get('minutes'))
.set('seconds', judgingStart.get('seconds'))
.set('hours', judgingStart.get('hours'))
.toDate();

const schedulerRequest: SchedulerRequest = {
Expand All @@ -109,7 +109,7 @@ router.post(
matches_start: settings.matchesStart,
practice_rounds: settings.practiceRounds,
ranking_rounds: settings.rankingRounds,
match_lenth_seconds: MATCH_LENGTH,
match_length_seconds: MATCH_LENGTH,
practice_match_cycle_time_seconds: settings.practiceCycleTimeSeconds,
ranking_match_cycle_time_seconds: settings.rankingCycleTimeSeconds,
stagger_matches: settings.isStaggered,
Expand All @@ -125,10 +125,13 @@ router.post(
}))
};

console.log(schedulerRequest);
console.log(JSON.stringify(schedulerRequest));

// TODO: await send request, validate response
// await initializeDivision(division, event);
await fetch('http://localhost:8000/scheduler', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify( schedulerRequest )}).then(res=>{
if (!res.ok) throw new Error("Scheduler failed to run")
});
await initializeDivision(division, event);

res.json({ ok: true });
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion libs/types/src/lib/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface SchedulerRequest {
matches_start: Date;
practice_rounds: number;
ranking_rounds: number;
match_lenth_seconds: number;
match_length_seconds: number;
practice_match_cycle_time_seconds: number;
ranking_match_cycle_time_seconds: number;
stagger_matches: boolean;
Expand Down

0 comments on commit 46eb690

Please sign in to comment.