Skip to content

Commit 1b2121f

Browse files
committed
Merge branch 'main' of https://github.com/uwblueprint/website-bp-be into INTF25-applicant-record-review-query
2 parents 2ce98b2 + daecb44 commit 1b2121f

23 files changed

+782
-16
lines changed

backend/typescript/graphql/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ import userResolvers from "./resolvers/userResolvers";
1717
import userType from "./types/userType";
1818
import reviewDashboardResolvers from "./resolvers/reviewDashboardResolvers";
1919
import reviewDashboardType from "./types/reviewDashboardType";
20+
import reviewedApplicantRecordTypes from "./types/reviewedApplicantRecordTypes";
21+
import reviewedApplicantRecordResolvers from "./resolvers/reviewedApplicantRecordResolver";
2022
import adminCommentResolvers from "./resolvers/adminCommentsResolvers";
2123
import adminCommentType from "./types/adminCommentsType";
24+
import applicantRecordResolvers from "./resolvers/applicantRecordResolvers";
25+
import applicantRecordType from "./types/applicantRecordType";
2226
import reviewPageType from "./types/reviewPageType";
2327
import reviewPageResolvers from "./resolvers/reviewPageResolvers";
2428

@@ -43,7 +47,9 @@ const executableSchema = makeExecutableSchema({
4347
simpleEntityType,
4448
userType,
4549
reviewDashboardType,
50+
reviewedApplicantRecordTypes,
4651
adminCommentType,
52+
applicantRecordType,
4753
reviewPageType,
4854
],
4955
resolvers: merge(
@@ -52,7 +58,9 @@ const executableSchema = makeExecutableSchema({
5258
simpleEntityResolvers,
5359
userResolvers,
5460
reviewDashboardResolvers,
61+
reviewedApplicantRecordResolvers,
5562
adminCommentResolvers,
63+
applicantRecordResolvers,
5664
reviewPageResolvers,
5765
),
5866
});
@@ -71,6 +79,8 @@ const graphQLMiddlewares = {
7179
userByEmail: authorizedByAdmin(),
7280
login: authorizedByAdmin(),
7381
users: authorizedByAdmin(),
82+
adminCommentsByApplicantRecordId: authorizedByAdmin(),
83+
adminCommentById: authorizedByAdmin(),
7484
},
7585
Mutation: {
7686
createEntity: authorizedByAllRoles(),
@@ -79,6 +89,10 @@ const graphQLMiddlewares = {
7989
createSimpleEntity: authorizedByAllRoles(),
8090
updateSimpleEntity: authorizedByAllRoles(),
8191
deleteSimpleEntity: authorizedByAllRoles(),
92+
createReviewedApplicantRecord: authorizedByAllRoles(),
93+
bulkCreateReviewedApplicantRecord: authorizedByAllRoles(),
94+
deleteReviewedApplicantRecord: authorizedByAllRoles(),
95+
bulkDeleteReviewedApplicantRecord: authorizedByAllRoles(),
8296
createUser: authorizedByAdmin(),
8397
updateUser: authorizedByAdmin(),
8498
deleteUserById: authorizedByAdmin(),

backend/typescript/graphql/resolvers/adminCommentsResolvers.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ import { CreateAdminCommentDTO, AdminCommentDTO } from "../../types";
55
const adminCommentService: IAdminCommentService = new AdminCommentService();
66

77
const adminCommentResolvers = {
8+
Query: {
9+
adminCommentsByApplicantRecordId: async (
10+
_parent: undefined,
11+
{ applicantRecordId }: { applicantRecordId: string },
12+
): Promise<AdminCommentDTO[]> => {
13+
const adminComments =
14+
await adminCommentService.getAdminCommentsByApplicantRecordId(
15+
applicantRecordId,
16+
);
17+
return adminComments;
18+
},
19+
adminCommentById: async (
20+
_parent: undefined,
21+
{ id }: { id: string },
22+
): Promise<AdminCommentDTO> => {
23+
const adminComment = await adminCommentService.getAdminCommentById(id);
24+
return adminComment;
25+
},
26+
},
827
Mutation: {
928
createAdminComment: async (
1029
_parent: undefined,
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import ApplicantRecordService from "../../services/implementations/applicantRecordService";
2+
import IApplicantRecordService from "../../services/interfaces/applicantRecordService";
3+
import { ApplicantRecordDTO } from "../../types";
4+
import { getErrorMessage } from "../../utilities/errorUtils";
5+
6+
const applicantRecordService: IApplicantRecordService =
7+
new ApplicantRecordService();
8+
9+
const applicantRecordResolvers = {
10+
Mutation: {
11+
setApplicantRecordFlag: async (
12+
_parent: undefined,
13+
{
14+
applicantRecordId,
15+
flagValue,
16+
}: { applicantRecordId: string; flagValue: boolean },
17+
): Promise<ApplicantRecordDTO> => {
18+
try {
19+
const applicantRecord =
20+
await applicantRecordService.setApplicantRecordFlag(
21+
applicantRecordId,
22+
flagValue,
23+
);
24+
return applicantRecord;
25+
} catch (error: unknown) {
26+
throw new Error(getErrorMessage(error));
27+
}
28+
},
29+
},
30+
};
31+
32+
export default applicantRecordResolvers;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import ReviewedApplicantRecordService from "../../services/implementations/reviewedApplicantRecordService";
2+
import {
3+
ReviewedApplicantRecordDTO,
4+
CreateReviewedApplicantRecordDTO,
5+
DeleteReviewedApplicantRecordDTO,
6+
} from "../../types";
7+
import { getErrorMessage } from "../../utilities/errorUtils";
8+
9+
const reviewedApplicantRecordService = new ReviewedApplicantRecordService();
10+
11+
const reviewedApplicantRecordResolvers = {
12+
Mutation: {
13+
createReviewedApplicantRecord: async (
14+
_parent: undefined,
15+
args: { input: CreateReviewedApplicantRecordDTO },
16+
): Promise<ReviewedApplicantRecordDTO> => {
17+
try {
18+
return await reviewedApplicantRecordService.createReviewedApplicantRecord(
19+
args.input,
20+
);
21+
} catch (error) {
22+
throw new Error(getErrorMessage(error));
23+
}
24+
},
25+
26+
bulkCreateReviewedApplicantRecord: async (
27+
_parent: undefined,
28+
args: { inputs: CreateReviewedApplicantRecordDTO[] },
29+
): Promise<ReviewedApplicantRecordDTO[]> => {
30+
try {
31+
return await reviewedApplicantRecordService.bulkCreateReviewedApplicantRecord(
32+
args.inputs,
33+
);
34+
} catch (error) {
35+
throw new Error(getErrorMessage(error));
36+
}
37+
},
38+
39+
deleteReviewedApplicantRecord: async (
40+
_parent: undefined,
41+
args: { input: DeleteReviewedApplicantRecordDTO },
42+
): Promise<ReviewedApplicantRecordDTO> => {
43+
try {
44+
return await reviewedApplicantRecordService.deleteReviewedApplicantRecord(
45+
args.input,
46+
);
47+
} catch (error) {
48+
throw new Error(getErrorMessage(error));
49+
}
50+
},
51+
52+
bulkDeleteReviewedApplicantRecord: async (
53+
_parent: undefined,
54+
args: { inputs: DeleteReviewedApplicantRecordDTO[] },
55+
): Promise<ReviewedApplicantRecordDTO[]> => {
56+
try {
57+
return await reviewedApplicantRecordService.bulkDeleteReviewedApplicantRecord(
58+
args.inputs,
59+
);
60+
} catch (error) {
61+
throw new Error(getErrorMessage(error));
62+
}
63+
},
64+
},
65+
};
66+
67+
export default reviewedApplicantRecordResolvers;

backend/typescript/graphql/types/adminCommentsType.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ const adminCommentsType = gql`
1616
comment: String!
1717
}
1818
19+
extend type Query {
20+
adminCommentsByApplicantRecordId(
21+
applicantRecordId: String!
22+
): [AdminCommentDTO!]!
23+
adminCommentById(id: String!): AdminCommentDTO!
24+
}
25+
1926
extend type Mutation {
2027
createAdminComment(adminComment: CreateAdminCommentDTO!): AdminCommentDTO!
2128
updateAdminComment(
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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(
18+
applicantRecordId: String!
19+
flagValue: Boolean!
20+
): ApplicantRecordDTO!
21+
}
22+
`;
23+
24+
export default applicantRecordType;

backend/typescript/graphql/types/reviewDashboardType.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { gql } from "apollo-server-express";
2-
import { ApplicationStatus, PositionTitle, ReviewerDTO } from "../../types";
32

43
const reviewDashboardType = gql`
54
type ReviewerDTO {
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { gql } from "apollo-server-express";
2+
3+
const reviewedApplicantRecordTypes = gql`
4+
enum SkillCategory {
5+
JUNIOR
6+
INTERMEDIATE
7+
SENIOR
8+
}
9+
10+
type Review {
11+
passionFSG: Int
12+
teamPlayer: Int
13+
desireToLearn: Int
14+
skill: Int
15+
skillCategory: SkillCategory
16+
}
17+
18+
input ReviewInput {
19+
passionFSG: Int
20+
teamPlayer: Int
21+
desireToLearn: Int
22+
skill: Int
23+
skillCategory: SkillCategory
24+
}
25+
26+
type ReviewedApplicantRecord {
27+
applicantRecordId: ID!
28+
reviewerId: Int!
29+
review: Review
30+
status: String
31+
score: Int
32+
reviewerHasConflict: Boolean
33+
}
34+
35+
input CreateReviewedApplicantRecordInput {
36+
applicantRecordId: ID!
37+
reviewerId: Int!
38+
review: ReviewInput
39+
status: String
40+
}
41+
42+
input DeleteReviewedApplicantRecord {
43+
applicantRecordId: ID!
44+
reviewerId: Int!
45+
}
46+
47+
extend type Mutation {
48+
createReviewedApplicantRecord(
49+
input: CreateReviewedApplicantRecordInput!
50+
): ReviewedApplicantRecord!
51+
52+
bulkCreateReviewedApplicantRecord(
53+
inputs: [CreateReviewedApplicantRecordInput!]!
54+
): [ReviewedApplicantRecord!]!
55+
56+
deleteReviewedApplicantRecord(
57+
input: DeleteReviewedApplicantRecord!
58+
): ReviewedApplicantRecord!
59+
60+
bulkDeleteReviewedApplicantRecord(
61+
inputs: [DeleteReviewedApplicantRecord!]!
62+
): [ReviewedApplicantRecord!]!
63+
}
64+
`;
65+
66+
export default reviewedApplicantRecordTypes;

0 commit comments

Comments
 (0)