Skip to content

Commit db7354b

Browse files
linter
1 parent b341617 commit db7354b

File tree

6 files changed

+98
-86
lines changed

6 files changed

+98
-86
lines changed

backend/typescript/graphql/resolvers/reviewedApplicantRecordResolver.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import ReviewedApplicantRecordService from "../../services/implementations/reviewedApplicantRecordService";
2-
import {
3-
ReviewedApplicantRecordDTO,
2+
import {
3+
ReviewedApplicantRecordDTO,
44
CreateReviewedApplicantRecordDTO,
5-
DeleteReviewedApplicantRecordDTO
5+
DeleteReviewedApplicantRecordDTO,
66
} from "../../types";
77
import { getErrorMessage } from "../../utilities/errorUtils";
88

@@ -15,7 +15,9 @@ const reviewedApplicantRecordResolvers = {
1515
args: { input: CreateReviewedApplicantRecordDTO },
1616
): Promise<ReviewedApplicantRecordDTO> => {
1717
try {
18-
return await reviewedApplicantRecordService.createReviewedApplicantRecord(args.input);
18+
return await reviewedApplicantRecordService.createReviewedApplicantRecord(
19+
args.input,
20+
);
1921
} catch (error) {
2022
throw new Error(getErrorMessage(error));
2123
}
@@ -26,7 +28,9 @@ const reviewedApplicantRecordResolvers = {
2628
args: { inputs: CreateReviewedApplicantRecordDTO[] },
2729
): Promise<ReviewedApplicantRecordDTO[]> => {
2830
try {
29-
return await reviewedApplicantRecordService.bulkCreateReviewedApplicantRecord(args.inputs);
31+
return await reviewedApplicantRecordService.bulkCreateReviewedApplicantRecord(
32+
args.inputs,
33+
);
3034
} catch (error) {
3135
throw new Error(getErrorMessage(error));
3236
}
@@ -38,7 +42,7 @@ const reviewedApplicantRecordResolvers = {
3842
): Promise<ReviewedApplicantRecordDTO> => {
3943
try {
4044
return await reviewedApplicantRecordService.deleteReviewedApplicantRecord(
41-
args.input
45+
args.input,
4246
);
4347
} catch (error) {
4448
throw new Error(getErrorMessage(error));
@@ -51,7 +55,7 @@ const reviewedApplicantRecordResolvers = {
5155
): Promise<ReviewedApplicantRecordDTO[]> => {
5256
try {
5357
return await reviewedApplicantRecordService.bulkDeleteReviewedApplicantRecord(
54-
args.inputs
58+
args.inputs,
5559
);
5660
} catch (error) {
5761
throw new Error(getErrorMessage(error));

backend/typescript/graphql/types/reviewedApplicantRecordTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ const reviewedApplicantRecordTypes = gql`
6262
): [ReviewedApplicantRecord!]!
6363
}
6464
`;
65-
65+
6666
export default reviewedApplicantRecordTypes;

backend/typescript/migrations/20251112023004-add-createdat-updatedat-to-reviewed-application.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ import { Migration } from "../umzug";
44
const TABLE_NAME = "reviewed_applicant_records";
55

66
export const up: Migration = async ({ context: sequelize }) => {
7-
await sequelize.getQueryInterface().addColumn(TABLE_NAME, "createdAt", {
8-
type: DataType.DATE,
9-
allowNull: false,
10-
defaultValue: DataType.NOW
11-
})
7+
await sequelize.getQueryInterface().addColumn(TABLE_NAME, "createdAt", {
8+
type: DataType.DATE,
9+
allowNull: false,
10+
defaultValue: DataType.NOW,
11+
});
1212

13-
await sequelize.getQueryInterface().addColumn(TABLE_NAME, "updatedAt", {
14-
type: DataType.DATE,
15-
allowNull: false,
16-
defaultValue: DataType.NOW
17-
})
13+
await sequelize.getQueryInterface().addColumn(TABLE_NAME, "updatedAt", {
14+
type: DataType.DATE,
15+
allowNull: false,
16+
defaultValue: DataType.NOW,
17+
});
1818
};
1919

2020
export const down: Migration = async ({ context: sequelize }) => {
21-
await sequelize.getQueryInterface().removeColumn(TABLE_NAME, "createdAt");
22-
await sequelize.getQueryInterface().removeColumn(TABLE_NAME, "updatedAt");
21+
await sequelize.getQueryInterface().removeColumn(TABLE_NAME, "createdAt");
22+
await sequelize.getQueryInterface().removeColumn(TABLE_NAME, "updatedAt");
2323
};
Lines changed: 63 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,82 @@
11
import { sequelize } from "../../models";
22
import ReviewedApplicantRecord from "../../models/reviewedApplicantRecord.model";
3-
import {
4-
ReviewedApplicantRecordDTO,
5-
CreateReviewedApplicantRecordDTO,
6-
DeleteReviewedApplicantRecordDTO
3+
import {
4+
ReviewedApplicantRecordDTO,
5+
CreateReviewedApplicantRecordDTO,
6+
DeleteReviewedApplicantRecordDTO,
77
} from "../../types";
88

99
import IReviewApplicantRecordService from "../interfaces/IReviewedApplicantRecordService";
1010

1111
class ReviewedApplicantRecordService implements IReviewApplicantRecordService {
12+
async createReviewedApplicantRecord(
13+
dto: CreateReviewedApplicantRecordDTO,
14+
): Promise<ReviewedApplicantRecordDTO> {
15+
const record = await ReviewedApplicantRecord.create(dto);
16+
return record.toJSON() as ReviewedApplicantRecordDTO;
17+
}
1218

13-
async createReviewedApplicantRecord(
14-
dto: CreateReviewedApplicantRecordDTO
15-
): Promise<ReviewedApplicantRecordDTO> {
16-
const record = await ReviewedApplicantRecord.create(dto);
17-
return record.toJSON() as ReviewedApplicantRecordDTO;
18-
}
19-
20-
async bulkCreateReviewedApplicantRecord(
21-
createReviewedApplicantRecordDTOs: CreateReviewedApplicantRecordDTO[]
22-
): Promise<ReviewedApplicantRecordDTO[]> {
23-
const reviewedApplicantRecords = await sequelize.transaction(async (t) => {
24-
const records = await ReviewedApplicantRecord.bulkCreate(
25-
createReviewedApplicantRecordDTOs,
26-
{ transaction: t }
27-
);
28-
return records;
29-
});
30-
31-
return reviewedApplicantRecords.map((record) =>
32-
record.toJSON() as ReviewedApplicantRecordDTO
33-
);
34-
}
19+
async bulkCreateReviewedApplicantRecord(
20+
createReviewedApplicantRecordDTOs: CreateReviewedApplicantRecordDTO[],
21+
): Promise<ReviewedApplicantRecordDTO[]> {
22+
const reviewedApplicantRecords = await sequelize.transaction(async (t) => {
23+
const records = await ReviewedApplicantRecord.bulkCreate(
24+
createReviewedApplicantRecordDTOs,
25+
{ transaction: t },
26+
);
27+
return records;
28+
});
3529

36-
async deleteReviewedApplicantRecord(deleteReviewedApplicantRecord: DeleteReviewedApplicantRecordDTO): Promise<ReviewedApplicantRecordDTO> {
37-
const applicantRecordId = deleteReviewedApplicantRecord.applicantRecordId;
38-
const reviewerId = deleteReviewedApplicantRecord.reviewerId;
39-
const record = await ReviewedApplicantRecord.findOne({ where: { applicantRecordId, reviewerId } });
30+
return reviewedApplicantRecords.map(
31+
(record) => record.toJSON() as ReviewedApplicantRecordDTO,
32+
);
33+
}
4034

41-
if (!record) {
42-
throw new Error("ReviewedApplicantRecord not found, delete failed");
43-
}
35+
async deleteReviewedApplicantRecord(
36+
deleteReviewedApplicantRecord: DeleteReviewedApplicantRecordDTO,
37+
): Promise<ReviewedApplicantRecordDTO> {
38+
const applicantRecordId = deleteReviewedApplicantRecord.applicantRecordId;
39+
const reviewerId = deleteReviewedApplicantRecord.reviewerId;
40+
const record = await ReviewedApplicantRecord.findOne({
41+
where: { applicantRecordId, reviewerId },
42+
});
4443

45-
await record.destroy();
46-
return record.toJSON() as ReviewedApplicantRecordDTO;
44+
if (!record) {
45+
throw new Error("ReviewedApplicantRecord not found, delete failed");
4746
}
4847

49-
async bulkDeleteReviewedApplicantRecord(deleteReviewedApplicantRecords: DeleteReviewedApplicantRecordDTO[]): Promise<ReviewedApplicantRecordDTO[]> {
50-
const deletedRecords = await sequelize.transaction(async (t) => {
51-
const records = await Promise.all(
52-
deleteReviewedApplicantRecords.map(({ applicantRecordId, reviewerId }) =>
53-
ReviewedApplicantRecord.findOne({
54-
where: { applicantRecordId, reviewerId },
55-
transaction: t,
56-
})
57-
)
58-
);
48+
await record.destroy();
49+
return record.toJSON() as ReviewedApplicantRecordDTO;
50+
}
5951

60-
if (records.some((r) => !r)) {
61-
throw new Error("Not all records were found, bulk delete failed");
62-
}
52+
async bulkDeleteReviewedApplicantRecord(
53+
deleteReviewedApplicantRecords: DeleteReviewedApplicantRecordDTO[],
54+
): Promise<ReviewedApplicantRecordDTO[]> {
55+
const deletedRecords = await sequelize.transaction(async (t) => {
56+
const records = await Promise.all(
57+
deleteReviewedApplicantRecords.map(
58+
({ applicantRecordId, reviewerId }) =>
59+
ReviewedApplicantRecord.findOne({
60+
where: { applicantRecordId, reviewerId },
61+
transaction: t,
62+
}),
63+
),
64+
);
6365

64-
const existingRecords = records as ReviewedApplicantRecord[];
65-
await Promise.all(existingRecords.map((r) => r.destroy({ transaction: t })));
66+
if (records.some((r) => !r)) {
67+
throw new Error("Not all records were found, bulk delete failed");
68+
}
6669

67-
return existingRecords;
68-
});
70+
const existingRecords = records as ReviewedApplicantRecord[];
71+
await Promise.all(
72+
existingRecords.map((r) => r.destroy({ transaction: t })),
73+
);
6974

70-
return deletedRecords.map((r) => r.toJSON() as ReviewedApplicantRecordDTO);
71-
}
75+
return existingRecords;
76+
});
77+
78+
return deletedRecords.map((r) => r.toJSON() as ReviewedApplicantRecordDTO);
79+
}
7280
}
7381

74-
export default ReviewedApplicantRecordService;
82+
export default ReviewedApplicantRecordService;
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {
2-
ReviewedApplicantRecordDTO,
3-
CreateReviewedApplicantRecordDTO,
4-
DeleteReviewedApplicantRecordDTO
1+
import {
2+
ReviewedApplicantRecordDTO,
3+
CreateReviewedApplicantRecordDTO,
4+
DeleteReviewedApplicantRecordDTO,
55
} from "../../types";
66

77
interface IReviewApplicantRecordService {
@@ -10,15 +10,15 @@ interface IReviewApplicantRecordService {
1010
* @Param createReviewedApplicantRecordDTO data to create reviewed applicant record
1111
*/
1212
createReviewedApplicantRecord(
13-
createReviewedApplicantRecordDTO: CreateReviewedApplicantRecordDTO
13+
createReviewedApplicantRecordDTO: CreateReviewedApplicantRecordDTO,
1414
): Promise<ReviewedApplicantRecordDTO>;
1515

1616
/**
1717
* Creates multiple reviewed applicant record entries in bulk
1818
* @Param createReviewedApplicantRecordDTOs array of data to create reviewed applicant records
1919
*/
2020
bulkCreateReviewedApplicantRecord(
21-
createReviewedApplicantRecordDTOs: CreateReviewedApplicantRecordDTO[]
21+
createReviewedApplicantRecordDTOs: CreateReviewedApplicantRecordDTO[],
2222
): Promise<ReviewedApplicantRecordDTO[]>;
2323

2424
/**
@@ -27,16 +27,16 @@ interface IReviewApplicantRecordService {
2727
* @Param reviewerId the ID of the reviewer
2828
*/
2929
deleteReviewedApplicantRecord(
30-
deleteReviewedApplicantRecord: DeleteReviewedApplicantRecordDTO
30+
deleteReviewedApplicantRecord: DeleteReviewedApplicantRecordDTO,
3131
): Promise<ReviewedApplicantRecordDTO>;
3232

3333
/**
3434
* Deletes multiple reviewed applicant record entries in bulk
3535
* @Param deleteReviewedApplicantRecord array of data to delete reviewed applicant records
3636
*/
3737
bulkDeleteReviewedApplicantRecord(
38-
deleteReviewedApplicantRecords: DeleteReviewedApplicantRecordDTO[]
38+
deleteReviewedApplicantRecords: DeleteReviewedApplicantRecordDTO[],
3939
): Promise<ReviewedApplicantRecordDTO[]>;
4040
}
4141

42-
export default IReviewApplicantRecordService;
42+
export default IReviewApplicantRecordService;

backend/typescript/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,12 @@ export type CreateReviewedApplicantRecordDTO = {
213213
reviewerId: number;
214214
review?: Review;
215215
reviewerHasConflict?: boolean;
216-
}
216+
};
217217

218218
export type DeleteReviewedApplicantRecordDTO = {
219219
applicantRecordId: string;
220220
reviewerId: number;
221-
}
221+
};
222222

223223
export type AdminCommentDTO = {
224224
id: string;

0 commit comments

Comments
 (0)