Skip to content

Commit

Permalink
Merge pull request #149 from chingu-x/feature/sprint_checkin_form_sub…
Browse files Browse the repository at this point in the history
…mission_status_for_user

Feature: sprint checkin form submission status for user
  • Loading branch information
Ajen07 committed May 14, 2024
2 parents fdbf79d + d3cf81f commit df5b6c5
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 1 deletion.
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
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

0 comments on commit df5b6c5

Please sign in to comment.