diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c2dc1d8..28e9b41f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ Another example [here](https://co-pilot.dev/changelog) - Add voyage project submission controller, service, e2e tests, responses seed ([#133](https://github.com/chingu-x/chingu-dashboard-be/pull/133)) - Add new endpoints to select/reset team project ideation ([#136](https://github.com/chingu-x/chingu-dashboard-be/pull/136)) - Add CASL ability for Access control ([#141](https://github.com/chingu-x/chingu-dashboard-be/pull/141)) +- Add sprint checkin form submission status for a user ([#149](https://github.com/chingu-x/chingu-dashboard-be/pull/149)) - new command to run both e2e and unit test ([#148](https://github.com/chingu-x/chingu-dashboard-be/pull/148)) ### Changed diff --git a/prisma/seed/responses/checkinform-responses.ts b/prisma/seed/responses/checkinform-responses.ts index 1e478aba..90798be1 100644 --- a/prisma/seed/responses/checkinform-responses.ts +++ b/prisma/seed/responses/checkinform-responses.ts @@ -19,6 +19,7 @@ export const populateCheckinFormResponse = async () => { }, }, }, + userId: true, }, }); diff --git a/src/sprints/sprints.service.ts b/src/sprints/sprints.service.ts index b1ff4482..205818a1 100644 --- a/src/sprints/sprints.service.ts +++ b/src/sprints/sprints.service.ts @@ -582,6 +582,7 @@ export class SprintsService { }, }, }); + return tx.formResponseCheckin.create({ data: { voyageTeamMemberId: diff --git a/src/users/entities/user.entity.ts b/src/users/entities/user.entity.ts index 5d0dbe1f..34a78d4c 100644 --- a/src/users/entities/user.entity.ts +++ b/src/users/entities/user.entity.ts @@ -58,4 +58,7 @@ export class UserEntity implements User { @ApiProperty() updatedAt: Date; + + @ApiProperty() + sprintCheckin: number[]; } diff --git a/src/users/users.response.ts b/src/users/users.response.ts index ee61f55f..7c5e8e45 100644 --- a/src/users/users.response.ts +++ b/src/users/users.response.ts @@ -145,4 +145,7 @@ export class PublicUserResponse extends OmitType(UserResponse, [ export class FullUserResponse extends UserResponse { @ApiProperty({ isArray: true }) voyageTeamMembers: VoyageTeamWithoutMember; + + @ApiProperty({ isArray: true }) + sprintCheckIn: number[]; } diff --git a/src/users/users.service.ts b/src/users/users.service.ts index 25d7a710..dd8e7991 100644 --- a/src/users/users.service.ts +++ b/src/users/users.service.ts @@ -76,9 +76,42 @@ export class UsersService { }, select: privateUserDetailSelect, }); + // get voyageTeamMemberIds + const teamMemberId: number[] = ( + await this.prisma.user.findUnique({ + where: { + id: userId, + }, + select: { + voyageTeamMembers: { + select: { + id: true, + }, + }, + }, + }) + ).voyageTeamMembers.map((teamMemberId) => teamMemberId.id); + + // get sprint checkin Ids + const sprintCheckInIds = ( + await this.prisma.formResponseCheckin.findMany({ + where: { + voyageTeamMemberId: { + in: teamMemberId, + }, + }, + select: { + sprintId: true, + }, + }) + ).map((sprintCheckInId) => sprintCheckInId.sprintId); + + // update user object with sprintCheckInIds + + const updatedUser = { ...user, sprintCheckIn: sprintCheckInIds }; if (!user) throw new NotFoundException("User not found"); - return this.formatUser(user); + return this.formatUser(updatedUser); } // full user detail, for dev purpose