Skip to content

Commit c0247f3

Browse files
Add Reviewed Applicant Record service mutators
1 parent 83b1a51 commit c0247f3

File tree

11 files changed

+519
-8
lines changed

11 files changed

+519
-8
lines changed

backend/typescript/graphql/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { makeExecutableSchema, gql } from "apollo-server-express";
22
import { applyMiddleware } from "graphql-middleware";
3-
import { merge } from "lodash";
3+
import { create, merge } from "lodash";
44

55
import {
66
isAuthorizedByEmail,
@@ -18,6 +18,8 @@ import userType from "./types/userType";
1818
import dashboardType from "./types/dashboardType";
1919
import dashboardResolvers from "./resolvers/dashboardResolvers";
2020
import reviewType from "./types/reviewType";
21+
import reviewedApplicantRecordType from "./types/reviewedApplicantRecordType";
22+
import reviewedApplicantRecordResolvers from "./resolvers/reviewedApplicantRecordResolver";
2123

2224
const query = gql`
2325
type Query {
@@ -41,13 +43,15 @@ const executableSchema = makeExecutableSchema({
4143
simpleEntityType,
4244
userType,
4345
dashboardType,
46+
reviewedApplicantRecordType,
4447
],
4548
resolvers: merge(
4649
authResolvers,
4750
entityResolvers,
4851
simpleEntityResolvers,
4952
userResolvers,
5053
dashboardResolvers,
54+
reviewedApplicantRecordResolvers,
5155
),
5256
});
5357

@@ -90,6 +94,12 @@ const graphQLMiddlewares = {
9094
logout: isAuthorizedByUserId("userId"),
9195
resetPassword: isAuthorizedByEmail("email"),
9296
sendSignInLink: authorizedByAllRoles(),
97+
98+
// this should be guarded by isAuthorizedReviewerForApplication once it is implemented
99+
createReviewedApplicantRecord: authorizedByAllRoles(),
100+
bulkCreateReviewedApplicantRecords: authorizedByAllRoles(),
101+
updateReviewedApplicantRecordReview: authorizedByAllRoles(),
102+
updateReviewedApplicantRecordStatus: authorizedByAllRoles(),
93103
},
94104
};
95105

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import ReviewedApplicantRecordService from "../../services/implementations/reviewedApplicantRecordService";
2+
import { IReviewedApplicantRecordService } from "../../services/interfaces/reviewedApplicantRecordService";
3+
import {
4+
Review,
5+
ReviewedApplicantRecordDTO,
6+
ReviewedApplicantRecordPK,
7+
ReviewStatus,
8+
} from "../../types";
9+
10+
const reviewedApplicantRecordService: IReviewedApplicantRecordService =
11+
new ReviewedApplicantRecordService();
12+
13+
const reviewedApplicantRecordResolvers = {
14+
Mutation: {
15+
createReviewedApplicantRecord: async (
16+
_parent: undefined,
17+
{
18+
reviewedApplicantRecordPK,
19+
}: { reviewedApplicantRecordPK: ReviewedApplicantRecordPK },
20+
): Promise<ReviewedApplicantRecordDTO> => {
21+
return reviewedApplicantRecordService.createReviewedApplicantRecord(
22+
reviewedApplicantRecordPK,
23+
);
24+
},
25+
26+
bulkCreateReviewedApplicantRecords: async (
27+
_parent: undefined,
28+
{
29+
reviewedApplicantRecordPKs,
30+
}: { reviewedApplicantRecordPKs: ReviewedApplicantRecordPK[] },
31+
): Promise<ReviewedApplicantRecordDTO[]> => {
32+
return reviewedApplicantRecordService.bulkCreateReviewedApplicantRecords(
33+
reviewedApplicantRecordPKs,
34+
);
35+
},
36+
37+
updateReviewedApplicantRecordReview: async (
38+
_parent: undefined,
39+
{
40+
reviewedApplicantRecordPK,
41+
review,
42+
}: {
43+
reviewedApplicantRecordPK: ReviewedApplicantRecordPK;
44+
review: Review;
45+
},
46+
): Promise<ReviewedApplicantRecordDTO> => {
47+
return reviewedApplicantRecordService.updateReviewedApplicantRecordReview(
48+
reviewedApplicantRecordPK,
49+
review,
50+
);
51+
},
52+
53+
updateReviewedApplicantRecordStatus: async (
54+
_parent: undefined,
55+
{
56+
reviewedApplicantRecordPK,
57+
status,
58+
}: {
59+
reviewedApplicantRecordPK: ReviewedApplicantRecordPK;
60+
status: ReviewStatus;
61+
},
62+
): Promise<ReviewedApplicantRecordDTO> => {
63+
return reviewedApplicantRecordService.updateReviewedApplicantRecordStatus(
64+
reviewedApplicantRecordPK,
65+
status,
66+
);
67+
},
68+
},
69+
};
70+
71+
export default reviewedApplicantRecordResolvers;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { gql } from "apollo-server-express";
2+
3+
const reviewedApplicantRecordType = gql`
4+
type Review {
5+
passionFSG: Int
6+
teamPlayer: Int
7+
desireToLearn: Int
8+
skill: Int
9+
skillCategory: SkillCategory
10+
}
11+
12+
enum SkillCategory {
13+
Junior
14+
Intermediate
15+
Senior
16+
}
17+
18+
input ReviewInput {
19+
passionFSG: Int
20+
teamPlayer: Int
21+
desireToLearn: Int
22+
skill: Int
23+
skillCategory: SkillCategory
24+
}
25+
26+
type ReviewedApplicantRecordDTO {
27+
applicantRecordId: ID!
28+
reviewerId: ID!
29+
review: Review
30+
status: String!
31+
}
32+
33+
input ReviewedApplicantRecordPK {
34+
reviewerId: ID!
35+
applicantRecordId: ID!
36+
}
37+
38+
extend type Mutation {
39+
createReviewedApplicantRecord(
40+
reviewedApplicantRecordPK: ReviewedApplicantRecordPK!
41+
): ReviewedApplicantRecordDTO!
42+
43+
bulkCreateReviewedApplicantRecords(
44+
reviewedApplicantRecordPKs: [ReviewedApplicantRecordPK!]!
45+
): [ReviewedApplicantRecordDTO!]!
46+
47+
updateReviewedApplicantRecordReview(
48+
reviewedApplicantRecordPK: ReviewedApplicantRecordPK!
49+
review: ReviewInput!
50+
): ReviewedApplicantRecordDTO!
51+
52+
updateReviewedApplicantRecordStatus(
53+
reviewedApplicantRecordPK: ReviewedApplicantRecordPK!
54+
status: String!
55+
): ReviewedApplicantRecordDTO!
56+
}
57+
`;
58+
59+
export default reviewedApplicantRecordType;
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { DataType } from "sequelize-typescript";
2+
import { Migration } from "../umzug";
3+
4+
const REVIEWED_APPLICANT_RECORDS_TABLE = "reviewed_applicant_records";
5+
const APPLICANT_RECORD_TABLE = "applicant_records";
6+
const POSITIONS_TABLE = "positions";
7+
8+
export const up: Migration = async ({ context: sequelize }) => {
9+
await sequelize
10+
.getQueryInterface()
11+
.addColumn(REVIEWED_APPLICANT_RECORDS_TABLE, "createdAt", {
12+
type: DataType.DATE,
13+
allowNull: true,
14+
defaultValue: DataType.NOW,
15+
});
16+
17+
await sequelize
18+
.getQueryInterface()
19+
.addColumn(REVIEWED_APPLICANT_RECORDS_TABLE, "updatedAt", {
20+
type: DataType.DATE,
21+
allowNull: true,
22+
defaultValue: DataType.NOW,
23+
});
24+
25+
await sequelize
26+
.getQueryInterface()
27+
.addColumn(APPLICANT_RECORD_TABLE, "createdAt", {
28+
type: DataType.DATE,
29+
allowNull: true,
30+
defaultValue: DataType.NOW,
31+
});
32+
33+
await sequelize
34+
.getQueryInterface()
35+
.addColumn(APPLICANT_RECORD_TABLE, "updatedAt", {
36+
type: DataType.DATE,
37+
allowNull: true,
38+
defaultValue: DataType.NOW,
39+
});
40+
41+
await sequelize.getQueryInterface().addColumn(POSITIONS_TABLE, "createdAt", {
42+
type: DataType.DATE,
43+
allowNull: true,
44+
defaultValue: DataType.NOW,
45+
});
46+
47+
await sequelize.getQueryInterface().addColumn(POSITIONS_TABLE, "updatedAt", {
48+
type: DataType.DATE,
49+
allowNull: true,
50+
defaultValue: DataType.NOW,
51+
});
52+
};
53+
54+
export const down: Migration = async ({ context: sequelize }) => {
55+
await sequelize
56+
.getQueryInterface()
57+
.removeColumn(REVIEWED_APPLICANT_RECORDS_TABLE, "createdAt");
58+
59+
await sequelize
60+
.getQueryInterface()
61+
.removeColumn(REVIEWED_APPLICANT_RECORDS_TABLE, "updatedAt");
62+
63+
await sequelize
64+
.getQueryInterface()
65+
.removeColumn(APPLICANT_RECORD_TABLE, "createdAt");
66+
67+
await sequelize
68+
.getQueryInterface()
69+
.removeColumn(APPLICANT_RECORD_TABLE, "updatedAt");
70+
71+
await sequelize
72+
.getQueryInterface()
73+
.removeColumn(POSITIONS_TABLE, "createdAt");
74+
75+
await sequelize
76+
.getQueryInterface()
77+
.removeColumn(POSITIONS_TABLE, "updatedAt");
78+
};

backend/typescript/models/applicant.model.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import { Column, DataType, Model, Table } from "sequelize-typescript";
55
@Table({ tableName: "applicants" })
66
export default class Applicant extends Model {
77
@Column({
8-
type: DataType.INTEGER,
8+
type: DataType.STRING,
99
primaryKey: true,
1010
unique: true,
11-
autoIncrement: true,
1211
})
1312
id!: string;
1413

backend/typescript/models/applicantRecord.model.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ import Position from "./position.model";
1818
@Table({ tableName: "applicant_records" })
1919
export default class ApplicantRecord extends Model {
2020
@Column({
21-
type: DataType.INTEGER,
21+
type: DataType.STRING,
2222
primaryKey: true,
2323
unique: true,
24-
autoIncrement: true,
2524
})
26-
id!: string;
25+
id!: number;
2726

2827
@ForeignKey(() => Applicant)
2928
@Column({ type: DataType.STRING })
@@ -47,4 +46,18 @@ export default class ApplicantRecord extends Model {
4746

4847
@Column({ type: DataType.JSONB, allowNull: true })
4948
extraInfo!: ApplicantRecordExtraInfo;
49+
50+
@Column({
51+
type: DataType.DATE,
52+
allowNull: true,
53+
defaultValue: DataType.NOW,
54+
})
55+
createdAt!: Date;
56+
57+
@Column({
58+
type: DataType.DATE,
59+
allowNull: true,
60+
defaultValue: DataType.NOW,
61+
})
62+
updatedAt!: Date;
5063
}

backend/typescript/models/position.model.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,18 @@ export default class Position extends Model {
88

99
@Column({ type: DataType.ENUM(...Object.values(Department)) })
1010
department!: Department;
11+
12+
@Column({
13+
type: DataType.DATE,
14+
allowNull: true,
15+
defaultValue: DataType.NOW,
16+
})
17+
createdAt!: Date;
18+
19+
@Column({
20+
type: DataType.DATE,
21+
allowNull: true,
22+
defaultValue: DataType.NOW,
23+
})
24+
updatedAt!: Date;
1125
}

backend/typescript/models/reviewedApplicantRecord.model.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,18 @@ export default class ReviewedApplicantRecord extends Model {
2929
defaultValue: ReviewStatusEnum.TODO,
3030
})
3131
status!: ReviewStatus;
32+
33+
@Column({
34+
type: DataType.DATE,
35+
allowNull: true,
36+
defaultValue: DataType.NOW,
37+
})
38+
createdAt!: Date;
39+
40+
@Column({
41+
type: DataType.DATE,
42+
allowNull: true,
43+
defaultValue: DataType.NOW,
44+
})
45+
updatedAt!: Date;
3246
}

0 commit comments

Comments
 (0)