From f6d22843383f7425bb320bce9d41cb3b5b737126 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Tue, 8 Oct 2024 13:39:51 +0200 Subject: [PATCH 1/9] fix(assignments-service): Flatten openAI and Moss config on patch --- .../src/assignment/assignment.controller.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/services/apps/assignments/src/assignment/assignment.controller.ts b/services/apps/assignments/src/assignment/assignment.controller.ts index 82171b27..ba8ee57b 100644 --- a/services/apps/assignments/src/assignment/assignment.controller.ts +++ b/services/apps/assignments/src/assignment/assignment.controller.ts @@ -112,15 +112,19 @@ export class AssignmentController { @Param('id', ObjectIdPipe) id: Types.ObjectId, @Body() dto: UpdateAssignmentDto, ): Promise { - const {token, classroom, ...rest} = dto; + const {token, ...rest} = dto; const update: UpdateQuery = rest; if (token) { update.token = generateToken(); } - if (classroom) { - // need to flatten the classroom object to prevent deleting the GitHub token all the time - for (const [key, value] of Object.entries(classroom)) { - update[`classroom.${key}`] = value; + for (const key of ['classroom', 'openAI', 'moss'] as const) { + const obj = rest[key]; + if (obj) { + delete update[key]; + // need to flatten these objects to prevent deleting the tokens all the time + for (const [subKey, value] of Object.entries(obj)) { + update[`${key}.${subKey}`] = value; + } } } return this.assignmentService.update(id, update); From 7ca4f3e10a0118aefc0cb55ab55ab9854263b40f Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Tue, 8 Oct 2024 13:41:49 +0200 Subject: [PATCH 2/9] fix(frontend): Save selected OpenAI model --- .../edit-assignment/code-search/code-search.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/assignment/modules/edit-assignment/code-search/code-search.component.html b/frontend/src/app/assignment/modules/edit-assignment/code-search/code-search.component.html index 669bea04..0983b2d9 100644 --- a/frontend/src/app/assignment/modules/edit-assignment/code-search/code-search.component.html +++ b/frontend/src/app/assignment/modules/edit-assignment/code-search/code-search.component.html @@ -35,7 +35,7 @@ @for (model of embeddingModels; track model.id) {
- +