Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: sprint checkin form submission status for user #149

Merged
merged 8 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions prisma/seed/responses/checkinform-responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const populateCheckinFormResponse = async () => {
},
},
},
userId: true,
},
});

Expand Down
1 change: 1 addition & 0 deletions src/sprints/sprints.service.ts
Ajen07 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ export class SprintsService {
},
},
});

return tx.formResponseCheckin.create({
data: {
voyageTeamMemberId:
Expand Down
3 changes: 3 additions & 0 deletions src/users/entities/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,7 @@ export class UserEntity implements User {

@ApiProperty()
updatedAt: Date;

@ApiProperty()
sprintCheckin: number[];
}
3 changes: 3 additions & 0 deletions src/users/users.response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
}
35 changes: 34 additions & 1 deletion src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading