Skip to content

Commit 6091978

Browse files
committed
add feature to flag applicant records
1 parent ea91602 commit 6091978

File tree

6 files changed

+100
-1
lines changed

6 files changed

+100
-1
lines changed

backend/typescript/graphql/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import reviewDashboardResolvers from "./resolvers/reviewDashboardResolvers";
1919
import reviewDashboardType from "./types/reviewDashboardType";
2020
import adminCommentResolvers from "./resolvers/adminCommentsResolvers";
2121
import adminCommentType from "./types/adminCommentsType";
22+
import applicantRecordResolvers from "./resolvers/applicantRecordResolvers";
23+
import applicantRecordType from "./types/applicantRecordType";
2224

2325
const query = gql`
2426
type Query {
@@ -42,6 +44,7 @@ const executableSchema = makeExecutableSchema({
4244
userType,
4345
reviewDashboardType,
4446
adminCommentType,
47+
applicantRecordType,
4548
],
4649
resolvers: merge(
4750
authResolvers,
@@ -50,6 +53,7 @@ const executableSchema = makeExecutableSchema({
5053
userResolvers,
5154
reviewDashboardResolvers,
5255
adminCommentResolvers,
56+
applicantRecordResolvers,
5357
),
5458
});
5559

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import ApplicantRecordService from "../../services/implementations/applicantRecordService";
2+
import IApplicantRecordService from "../../services/interfaces/applicantRecordService";
3+
import { ApplicantRecordDTO } from "../../types";
4+
5+
const applicantRecordService: IApplicantRecordService = new ApplicantRecordService();
6+
7+
const applicantRecordResolvers = {
8+
Mutation: {
9+
setApplicantRecordFlag: async (
10+
_parent: undefined,
11+
{ applicantRecordId, flagValue }: { applicantRecordId: string; flagValue: boolean },
12+
): Promise<ApplicantRecordDTO> => {
13+
const applicantRecord = await applicantRecordService.setApplicantRecordFlag(
14+
applicantRecordId, flagValue,
15+
);
16+
return applicantRecord;
17+
},
18+
},
19+
};
20+
21+
export default applicantRecordResolvers;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { gql } from "apollo-server-express";
2+
3+
const applicantRecordType = gql`
4+
type ApplicantRecordDTO {
5+
id: String!
6+
applicantId: String!
7+
position: String!
8+
roleSpecificQuestions: [String!]!
9+
choice: Int!
10+
status: String!
11+
skillCategory: String
12+
combined_score: Int
13+
isApplicantFlagged: Boolean!
14+
}
15+
16+
extend type Mutation {
17+
setApplicantRecordFlag(applicantRecordId: String!, flagValue: Boolean!): ApplicantRecordDTO!
18+
}
19+
`;
20+
21+
export default applicantRecordType;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { ApplicantRecordDTO, PositionTitle } from "../../types";
2+
import { getErrorMessage } from "../../utilities/errorUtils";
3+
import logger from "../../utilities/logger";
4+
import ApplicantRecord from "../../models/applicantRecord.model";
5+
import IApplicantRecordService from "../interfaces/applicantRecordService";
6+
7+
const Logger = logger(__filename);
8+
9+
class ApplicantRecordService implements IApplicantRecordService {
10+
/* eslint-disable class-methods-use-this */
11+
async setApplicantRecordFlag(
12+
applicantRecordId: string,
13+
flagValue: boolean,
14+
): Promise<ApplicantRecordDTO> {
15+
try {
16+
const applicantRecord = await ApplicantRecord.findByPk(applicantRecordId);
17+
if (!applicantRecord) {
18+
throw new Error(`ApplicantRecord with id ${applicantRecordId} not found.`);
19+
}
20+
applicantRecord.isApplicantFlagged = flagValue;
21+
await applicantRecord.save();
22+
return {
23+
id: String(applicantRecord.id),
24+
applicantId: String(applicantRecord.applicantId),
25+
position: applicantRecord.position as PositionTitle,W
26+
roleSpecificQuestions: applicantRecord.roleSpecificQuestions,
27+
choice: applicantRecord.choice,
28+
status: applicantRecord.status,
29+
skillCategory: applicantRecord.skillCategory,
30+
combined_score: applicantRecord.combined_score,
31+
isApplicantFlagged: applicantRecord.isApplicantFlagged,
32+
};
33+
} catch (error: unknown) {
34+
Logger.error(
35+
`Failed to set applicant record flag. Reason = ${getErrorMessage(error)}`,
36+
);
37+
throw error;
38+
}
39+
}
40+
}
41+
42+
export default ApplicantRecordService;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ApplicantRecordDTO } from "../../types";
2+
3+
interface IApplicantRecordService {
4+
setApplicantRecordFlag(
5+
applicantRecordId: string,
6+
flagValue: boolean,
7+
): Promise<ApplicantRecordDTO>;
8+
}
9+
10+
export default IApplicantRecordService;

backend/typescript/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,15 @@ export type ApplicantDTO = {
7878
};
7979

8080
export type ApplicantRecordDTO = {
81-
id: number;
81+
id: string;
8282
applicantId: string;
8383
position: PositionTitle; // EDIT LATER
8484
roleSpecificQuestions: string[];
8585
choice: number;
8686
status: ApplicationStatus;
8787
skillCategory?: SkillCategory;
8888
combined_score?: number | null;
89+
isApplicantFlagged: boolean;
8990
};
9091

9192
export type ApplicationStatus =

0 commit comments

Comments
 (0)