Skip to content

Commit

Permalink
refactor: move to node v20
Browse files Browse the repository at this point in the history
  • Loading branch information
williams-jack committed Aug 8, 2024
1 parent 8cc195b commit a769791
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dev.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
working-directory: orchestrator
strategy:
matrix:
node-version: ["21.0.0"]
node-version: ["20.11.0"]
steps:
- name: checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion orchestrator/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
21.0.0
v20.11.0
2 changes: 1 addition & 1 deletion orchestrator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:21.0.0-bullseye-slim
FROM node:20.11.0-bullseye-slim

WORKDIR /usr

Expand Down
17 changes: 16 additions & 1 deletion orchestrator/packages/db/src/server-operations/get-jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,28 @@ const getAllGradingJobs = (): Promise<Array<GradingJob>> => prismaInstance.$tran
createdAt: 'desc'
}
});
const submitterIDToJobs: Map<number, Array<Job>> = Map.groupBy(submitterJobs, (j: Job) => j.submitterID!);
const submitterIDToJobs: Map<number, Array<Job>> = groupBySubmitterID(submitterJobs);
return reservations.map((r) =>
r.submitterID === null ?
combineJobAndReservation(r, r.job!) :
combineJobAndReservation(r, submitterIDToJobs.get(r.submitterID)!.shift()!));
});

const groupBySubmitterID = (submitterJobs: Array<Job>) => {
const submitterIDToJobs: Map<number, Array<Job>> = new Map();
submitterJobs.forEach((j) => {
if (j.submitterID === null) {
throw TypeError("Cannot group by a null submitter ID.");
}
if (!submitterIDToJobs.has(j.submitterID!)) {
submitterIDToJobs.set(j.submitterID, [j]);
} else {
submitterIDToJobs.set(j.submitterID, [...submitterIDToJobs.get(j.submitterID)!, j]);
}
});
return submitterIDToJobs;
}

const combineJobAndReservation = (r: Reservation, j: Job): GradingJob => ({
...j.config as object as GradingJobConfig,
release_at: r.releaseAt,
Expand Down

0 comments on commit a769791

Please sign in to comment.