Skip to content

Commit e0321c4

Browse files
.
1 parent aa4d138 commit e0321c4

File tree

9 files changed

+143
-28
lines changed

9 files changed

+143
-28
lines changed

backend/typescript/graphql/types/applicantRecordType.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
import { gql } from "apollo-server-express";
22

33
const applicantRecordType = gql`
4-
enum ApplicationStatus {
5-
Applied
6-
InReview
7-
Reviewed
8-
Interview
9-
InterviewComplete
10-
Offer
11-
NotConsidered
12-
}
13-
144
enum SkillCategory {
155
Junior
166
Intermediate
@@ -23,7 +13,7 @@ const applicantRecordType = gql`
2313
position: String!
2414
roleSpecificQuestions: [String!]!
2515
choice: Int!
26-
status: ApplicationStatus!
16+
status: String!
2717
skillCategory: SkillCategory
2818
}
2919
@@ -32,7 +22,7 @@ const applicantRecordType = gql`
3222
position: String!
3323
roleSpecificQuestions: [String!]!
3424
choice: Int!
35-
status: ApplicationStatus!
25+
status: String!
3626
skillCategory: SkillCategory
3727
}
3828

backend/typescript/graphql/types/reviewedApplicantRecordType.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import { gql } from "apollo-server-express";
22

33
const reviewedApplicantRecordType = gql`
4-
enum ReviewStatusEnum {
5-
Todo
6-
InProgress
7-
Done
8-
Conflict
9-
}
10-
114
type Review {
125
passionFSG: Int
136
teamPlayer: Int
@@ -16,6 +9,12 @@ const reviewedApplicantRecordType = gql`
169
skillCategory: SkillCategory
1710
}
1811
12+
enum SkillCategory {
13+
Junior
14+
Intermediate
15+
Senior
16+
}
17+
1918
input ReviewInput {
2019
passionFSG: Int
2120
teamPlayer: Int
@@ -48,7 +47,7 @@ const reviewedApplicantRecordType = gql`
4847
4948
updateReviewedApplicantRecordStatus(
5049
reviewedApplicantRecordPK: ReviewedApplicantRecordPK!
51-
status: ReviewStatusEnum!
50+
status: String!
5251
): ReviewedApplicantRecordDTO!
5352
}
5453
`;
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: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ 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
})
2625
id!: number;
2726

@@ -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
}

backend/typescript/services/implementations/applicantRecordService.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { randomUUID } from "crypto";
12
import { sequelize } from "../../models";
23
import logger from "../../utilities/logger";
34
import { getErrorMessage } from "../../utilities/errorUtils";
@@ -12,15 +13,17 @@ class ApplicantRecordService implements IApplicantRecordService {
1213
applicantRecords: ApplicantRecordDTO[],
1314
): Promise<ApplicantRecordDTO[]> => {
1415
try {
16+
const applicantRecordsWithId = applicantRecords.map((record) => ({
17+
...record,
18+
id: randomUUID(),
19+
}));
1520
const createdRecords = await sequelize.transaction(async (transaction) =>
16-
ApplicantRecord.bulkCreate(applicantRecords, {
21+
ApplicantRecord.bulkCreate(applicantRecordsWithId, {
1722
transaction,
1823
returning: true,
1924
}),
2025
);
2126

22-
console.log(`Created ${createdRecords.length} applicant records`);
23-
2427
return createdRecords as ApplicantRecordDTO[];
2528
} catch (error) {
2629
Logger.error(

backend/typescript/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ export type ApplicationStatus =
115115
| "Offer"
116116
| "Not Considered";
117117

118-
export type SkillCategory = "Junior" | "Intermediate" | "Senior";
118+
export enum SkillCategoryEnum {
119+
Junior = "Junior",
120+
Intermediate = "Intermediate",
121+
Senior = "Senior",
122+
}
123+
export type SkillCategory = `${SkillCategoryEnum}`;
119124

120125
export type ApplicantRecordExtraInfo = {
121126
adminReview?: string;

0 commit comments

Comments
 (0)