Skip to content

Commit 8b662d0

Browse files
authored
Fix course ID not being populated in the database (#989)
1 parent c19a963 commit 8b662d0

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

server/src/user/user.service.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,23 @@ export class UserService {
290290
},
291291
});
292292

293-
const update_classes = _timetable.selectedClasses.map((c) =>
294-
this.prisma.class.upsert({
295-
where: { id: c.id },
296-
update: c,
293+
const update_classes = _timetable.selectedClasses.map((c) => {
294+
// TODO: Get the actual field instead of computing it
295+
// classNo is currently a string such as COMP6420Undergraduate-11965-T1-2025
296+
// courseId should be a string such as COMP6420Undergraduate
297+
const selectedClass = {
298+
courseId: c.classNo.split('-')[0],
299+
...c,
300+
};
301+
return this.prisma.class.upsert({
302+
where: { id: selectedClass.id },
303+
update: selectedClass,
297304
create: {
298-
...c,
305+
...selectedClass,
299306
timetableId: _timetableId,
300307
},
301-
}),
302-
);
308+
});
309+
});
303310

304311
await this.prisma.$transaction([
305312
update_timetable,

0 commit comments

Comments
 (0)