Skip to content

Commit

Permalink
Merge pull request #158 from chingu-x/feat/add_voyage_project_submiss…
Browse files Browse the repository at this point in the history
…ion_status
  • Loading branch information
timDeHof committed May 29, 2024
2 parents c25f695 + 250f0ce commit fc0dde7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Another example [here](https://co-pilot.dev/changelog)
- 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))
- Add voyage project submission status to `/me` endpoint ([#158](https://github.com/chingu-x/chingu-dashboard-be/pull/158))

### Changed

Expand Down
1 change: 1 addition & 0 deletions src/global/selects/users.select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const privateUserDetailSelect = {
},
},
},
FormResponseVoyageProject: true,
},
},
voyageRole: {
Expand Down
28 changes: 25 additions & 3 deletions src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export class UsersService {
},
select: privateUserDetailSelect,
});

if (!user) throw new NotFoundException("User not found");
// get voyageTeamMemberIds
const teamMemberId: number[] = (
await this.prisma.user.findUnique({
Expand Down Expand Up @@ -107,10 +109,30 @@ export class UsersService {
).map((sprintCheckInId) => sprintCheckInId.sprintId);

// update user object with sprintCheckInIds
const updatedUser = {
...user,
sprintCheckIn: sprintCheckInIds,
voyageTeamMembers: user.voyageTeamMembers.map((teamMember) => {
if (teamMember.voyageTeam.FormResponseVoyageProject) {
return {
...teamMember,
voyageTeam: {
...teamMember.voyageTeam,
projectSubmitted: true,
},
};
} else {
return {
...teamMember,
voyageTeam: {
...teamMember.voyageTeam,
projectSubmitted: false,
},
};
}
}),
};

const updatedUser = { ...user, sprintCheckIn: sprintCheckInIds };

if (!user) throw new NotFoundException("User not found");
return this.formatUser(updatedUser);
}

Expand Down

0 comments on commit fc0dde7

Please sign in to comment.