Skip to content

Commit 6e45d84

Browse files
authored
#161 fixing trainee-applicants page issue (#162)
* fix(#161): update seeders and model * fix(#161): remove irrelevant records
1 parent 254edca commit 6e45d84

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

Diff for: src/models/traineeApplicant.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,18 @@ const TraineeApplicantSchema = new Schema(
6464
},
6565
coverLetterUrl: {
6666
type: String,
67-
required: false
67+
required: false,
68+
default: 'http://example.com/coverLetter.pdf'
6869
},
6970
idDocumentUrl: {
7071
type: String,
71-
required: false
72+
required: false,
73+
default: 'http://example.com/idDocument.pdf'
7274
},
7375
resumeUrl: {
7476
type: String,
75-
required: false
77+
required: false,
78+
default: 'http://example.com/resume.pdf'
7679
}
7780

7881
},

Diff for: src/seeders/DelTrainee.ts

+32-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import TraineeApplicant from '../models/traineeApplicant';
1+
import TraineeApplicant from '../models/traineeApplicant';
22
import { applicationCycle } from '../models/applicationCycle';
3+
import { traineEAttributes } from "../models/traineeAttribute";
34

45

56
const seedDeleteTrainee = async () => {
67
const cycle = await applicationCycle.findOne();
7-
8+
89
if (!cycle) {
9-
return;
10+
return;
1011
}
1112

1213
const deleteTrainee = [
@@ -15,44 +16,64 @@ const seedDeleteTrainee = async () => {
1516
firstName: 'Ben',
1617
lastName: 'iraa',
1718
deleted_at: false,
18-
cycle_id: cycle._id
19-
19+
cycle_id: cycle._id,
20+
coverLetterUrl: "http://example.com/coverLetter.pdf",
21+
idDocumentUrl: "http://example.com/idDocument.pdf",
22+
resumeUrl: "http://example.com/resume.pdf"
23+
2024
},
2125
{
2226
2327
firstName: 'Test',
2428
lastName: 'user',
2529
deleted_at: false,
26-
cycle_id: cycle._id
27-
30+
cycle_id: cycle._id,
31+
coverLetterUrl: "http://example.com/coverLetter.pdf",
32+
idDocumentUrl: "http://example.com/idDocument.pdf",
33+
resumeUrl: "http://example.com/resume.pdf"
34+
35+
2836
},
2937
{
3038
3139
firstName: 'iradukunda',
3240
lastName: 'benjamin',
3341
deleted_at: false,
34-
cycle_id: cycle._id
42+
cycle_id: cycle._id,
43+
coverLetterUrl: "http://example.com/coverLetter.pdf",
44+
idDocumentUrl: "http://example.com/idDocument.pdf",
45+
resumeUrl: "http://example.com/resume.pdf"
46+
3547

3648
},
3749
{
3850
3951
firstName: 'carlos',
4052
lastName: 'Bz',
4153
deleted_at: false,
42-
cycle_id: cycle._id
54+
cycle_id: cycle._id,
55+
coverLetterUrl: "http://example.com/coverLetter.pdf",
56+
idDocumentUrl: "http://example.com/idDocument.pdf",
57+
resumeUrl: "http://example.com/resume.pdf"
58+
4359

4460
},
4561
{
4662
4763
firstName: 'blaise',
4864
lastName: 'k',
4965
deleted_at: false,
50-
cycle_id: cycle._id
66+
cycle_id: cycle._id,
67+
coverLetterUrl: "http://example.com/coverLetter.pdf",
68+
idDocumentUrl: "http://example.com/idDocument.pdf",
69+
resumeUrl: "http://example.com/resume.pdf"
70+
5171

5272
},
5373
];
54-
await TraineeApplicant.deleteMany({deleteTrainee});
74+
await TraineeApplicant.deleteMany({ deleteTrainee });
5575
await TraineeApplicant.insertMany(deleteTrainee);
76+
await traineEAttributes.deleteMany({});
5677
return null;
5778
}
5879
export default seedDeleteTrainee;

Diff for: src/seeders/applications.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { jobModels } from '../models/jobModels';
44
import { ProgramModel } from '../models/programModel';
55
import { cohortModels } from '../models/cohortModel';
66
import { applicationCycle } from '../models/applicationCycle';
7+
import JobApplication from "../models/JobApplication";
78

89
const seedApplications = async () => {
910
const program = await ProgramModel.findOne();
@@ -96,6 +97,7 @@ const seedApplications = async () => {
9697

9798
await applicant_records.deleteMany({});
9899
await applicant_records.insertMany(applicants);
100+
await JobApplication.deleteMany({});
99101

100102
console.log('Database seeded successfully');
101103
};

0 commit comments

Comments
 (0)