Skip to content

Commit

Permalink
BC-8362 - RoomMember groups are shown in class administration and dur…
Browse files Browse the repository at this point in the history
…ing sync of courses with groups (#5333)

* allow more group types in filtering for class groups

* specifying which groups can be chosen for course synch
  • Loading branch information
MartinSchuhmacher authored and hoeppner-dataport committed Nov 18, 2024
1 parent eca5809 commit 56a4414
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
9 changes: 9 additions & 0 deletions apps/server/src/modules/group/domain/group-aggregate.scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ export class GroupAggregateScope extends MongoDbScope<GroupEntity> {
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',
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/group/uc/class-group.uc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ describe('ClassGroupUc', () => {

expect(groupService.findGroups).toHaveBeenCalledWith<[GroupFilter]>({
userId: teacherUser.id,
groupTypes: [GroupTypes.CLASS],
groupTypes: [GroupTypes.CLASS, GroupTypes.COURSE, GroupTypes.OTHER],
});
});
});
Expand Down Expand Up @@ -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],
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/group/uc/class-group.uc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class ClassGroupUc {
}

private async findGroupsForSchool(schoolId: EntityId): Promise<ClassInfoDto[]> {
const filter: GroupFilter = { schoolId, groupTypes: [GroupTypes.CLASS] };
const filter: GroupFilter = { schoolId, groupTypes: [GroupTypes.CLASS, GroupTypes.COURSE, GroupTypes.OTHER] };

const groups: Page<Group> = await this.groupService.findGroups(filter);

Expand All @@ -227,7 +227,7 @@ export class ClassGroupUc {
}

private async findGroupsForUser(userId: EntityId): Promise<ClassInfoDto[]> {
const filter: GroupFilter = { userId, groupTypes: [GroupTypes.CLASS] };
const filter: GroupFilter = { userId, groupTypes: [GroupTypes.CLASS, GroupTypes.COURSE, GroupTypes.OTHER] };

const groups: Page<Group> = await this.groupService.findGroups(filter);

Expand Down

0 comments on commit 56a4414

Please sign in to comment.