Skip to content

Initial scheduling algorithm and judging round mutation#8

Open
HarshitaJindia19 wants to merge 16 commits intomainfrom
HMTV2-13-schedule-algorithm
Open

Initial scheduling algorithm and judging round mutation#8
HarshitaJindia19 wants to merge 16 commits intomainfrom
HMTV2-13-schedule-algorithm

Conversation

@HarshitaJindia19
Copy link

  • Created a scheduler.ts which takes a list of teams and judges to generate time-slotted assignments. Like a round-robin style algorithm.
  • Added a generateSchedule mutation in judging-rounds that fetches from the organization and user data from the database, and adds the scheduling information to the judgingAssignments table.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use db push! we shouldn't have any migration files to deal with.

https://orm.drizzle.team/docs/migrations --> we are using the codebase first approach.

<h1 className={styles.welcome}>Schedule</h1>
<ul>
{mySchedule.map((timeSlot) => (
<li key={`${timeSlot.teamName}-${timeSlot.start.getTime()}`}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some build errors here. run a build locally and fix errors before pushing up a branch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great start - looking at this it seems that the schedule will kind of create a diagonal on a calendar. looking at the currentTime pointer - it is incremented each time a team is scheduled and done. that means that judge 1 is idle while judge 0 judges, and only begins judging the next team after that first team is done (if that makes sense). lets extend this algorithm - many judges are available concurrently and the schedule should compensate for that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I edited the scheduler.ts so that now it assigns a judge to each team. Once all judges have been assigned a team, it moves to the remaining of teams, until all teams have been assigned a time slot. This way no judge will be idle.

I am currently working on making it so that multiple judges can be assigned to a team.

const judges = await ctx.db.query.user.findMany({});

// Run scheduling algorithm
const schedule = createSchedule(teams, judges, round.startTime, 15);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic number, can we make this a user input?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also consider using a try catch or adding some common error checking here. like what if u queried no judges ? no teams? should the schedule run at all?

});
}

return { sucess: true };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo - success

const schedule = createSchedule(teams, judges, round.startTime, 15);

// Insert assignments
for (const slot of schedule) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inserting one by one might be slow. look into a batch or bulk insert. also look into try catch blocks for a more graceful exit if there is a failure.

}

// Get all teams (organizations)
const teams = await ctx.db.query.organization.findMany();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remember that this should be filtered data and not everything in the database. we only want teams that have passed a certain round (prescreen, round 1, etc). might be blocked by justin's pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants