From 5c5678c6fc38475e49cc86e6a65bb9f8c7667d1a Mon Sep 17 00:00:00 2001 From: MartinSchuhmacher Date: Fri, 8 Nov 2024 10:00:34 +0100 Subject: [PATCH 1/3] allow more group types in filtering --- apps/server/src/modules/group/uc/class-group.uc.spec.ts | 4 ++-- apps/server/src/modules/group/uc/class-group.uc.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/server/src/modules/group/uc/class-group.uc.spec.ts b/apps/server/src/modules/group/uc/class-group.uc.spec.ts index 1dd1f18dc5d..b19e866c704 100644 --- a/apps/server/src/modules/group/uc/class-group.uc.spec.ts +++ b/apps/server/src/modules/group/uc/class-group.uc.spec.ts @@ -414,7 +414,7 @@ describe('ClassGroupUc', () => { expect(groupService.findGroups).toHaveBeenCalledWith<[GroupFilter]>({ userId: teacherUser.id, - groupTypes: [GroupTypes.CLASS], + groupTypes: [GroupTypes.CLASS, GroupTypes.COURSE, GroupTypes.OTHER], }); }); }); @@ -777,7 +777,7 @@ describe('ClassGroupUc', () => { expect(groupService.findGroups).toHaveBeenCalledWith<[GroupFilter]>({ schoolId: teacherUser.school.id, - groupTypes: [GroupTypes.CLASS], + groupTypes: [GroupTypes.CLASS, GroupTypes.COURSE, GroupTypes.OTHER], }); }); }); diff --git a/apps/server/src/modules/group/uc/class-group.uc.ts b/apps/server/src/modules/group/uc/class-group.uc.ts index bede2d7441b..77ce030d3df 100644 --- a/apps/server/src/modules/group/uc/class-group.uc.ts +++ b/apps/server/src/modules/group/uc/class-group.uc.ts @@ -217,7 +217,7 @@ export class ClassGroupUc { } private async findGroupsForSchool(schoolId: EntityId): Promise { - const filter: GroupFilter = { schoolId, groupTypes: [GroupTypes.CLASS] }; + const filter: GroupFilter = { schoolId, groupTypes: [GroupTypes.CLASS, GroupTypes.COURSE, GroupTypes.OTHER] }; const groups: Page = await this.groupService.findGroups(filter); @@ -227,7 +227,7 @@ export class ClassGroupUc { } private async findGroupsForUser(userId: EntityId): Promise { - const filter: GroupFilter = { userId, groupTypes: [GroupTypes.CLASS] }; + const filter: GroupFilter = { userId, groupTypes: [GroupTypes.CLASS, GroupTypes.COURSE, GroupTypes.OTHER] }; const groups: Page = await this.groupService.findGroups(filter); From e3a5266a60379130cffc1e230aa3a5d29f4ece6a Mon Sep 17 00:00:00 2001 From: MartinSchuhmacher Date: Fri, 8 Nov 2024 10:57:36 +0100 Subject: [PATCH 2/3] specifying which groups can be chosen for course synch --- .../src/modules/group/domain/group-aggregate.scope.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/server/src/modules/group/domain/group-aggregate.scope.ts b/apps/server/src/modules/group/domain/group-aggregate.scope.ts index 684836e34a6..1e2ffe9203a 100644 --- a/apps/server/src/modules/group/domain/group-aggregate.scope.ts +++ b/apps/server/src/modules/group/domain/group-aggregate.scope.ts @@ -29,6 +29,15 @@ export class GroupAggregateScope extends MongoDbScope { byAvailableForSync(value: boolean | undefined): this { if (value) { this.pipeline.push( + { + $match: { + $or: [ + { type: { $eq: GroupTypes.CLASS } }, + { type: { $eq: GroupTypes.COURSE } }, + { type: { $eq: GroupTypes.OTHER } }, + ], + }, + }, { $lookup: { from: 'courses', From 0c9d58060d1dd95c3832ce20319511525b0c9cb5 Mon Sep 17 00:00:00 2001 From: MartinSchuhmacher Date: Fri, 8 Nov 2024 11:08:21 +0100 Subject: [PATCH 3/3] fixing test --- .../modules/group/domain/group-aggregate.scope.spec.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/server/src/modules/group/domain/group-aggregate.scope.spec.ts b/apps/server/src/modules/group/domain/group-aggregate.scope.spec.ts index bd37cd922fd..8c9a565b4ca 100644 --- a/apps/server/src/modules/group/domain/group-aggregate.scope.spec.ts +++ b/apps/server/src/modules/group/domain/group-aggregate.scope.spec.ts @@ -99,6 +99,15 @@ describe(GroupAggregateScope.name, () => { const result = new GroupAggregateScope().byAvailableForSync(true).build(); expect(result).toEqual([ + { + $match: { + $or: [ + { type: { $eq: GroupTypes.CLASS } }, + { type: { $eq: GroupTypes.COURSE } }, + { type: { $eq: GroupTypes.OTHER } }, + ], + }, + }, { $lookup: { from: 'courses',