Skip to content

Commit 5b7212f

Browse files
committed
feat(interview-scheduler): add a limit on max. allowed rounds
Add a limit on maximum allowed number of interview rounds.
1 parent 0b57894 commit 5b7212f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

app-constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ const Interviews = {
6666
XaiTemplate: {
6767
'interview-30': 30,
6868
'interview-60': 60
69-
}
69+
},
70+
MaxAllowedCount: 3
7071
}
7172

7273
const ChallengeStatus = {

src/services/InterviewService.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ async function requestInterview (currentUser, jobCandidateId, interview) {
125125
const round = await Interview.count({
126126
where: { jobCandidateId }
127127
})
128+
129+
// throw error if candidate has already had MaxAllowedCount interviews
130+
if (round >= InterviewConstants.MaxAllowedCount) {
131+
throw new errors.ConflictError(`You've reached the maximum allowed number (${InterviewConstants.MaxAllowedCount}) of interviews for this candidate.`)
132+
}
128133
interview.round = round + 1
129134

130135
try {

0 commit comments

Comments
 (0)