Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seeders for jobs, programs and cohorts #94

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/seeders/DelTrainee.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
import TraineeApplicant from '../models/traineeApplicant';
import { applicationCycle } from '../models/applicationCycle';


const seedDeleteTrainee = async () => {
const cycle = await applicationCycle.findOne();

if (!cycle) {
return;
}

const deleteTrainee = [
{
email: '[email protected]',
firstName: 'Ben',
lastName: 'iraa',
deleted_at: false
deleted_at: false,
cycle_id: cycle._id

},
{
email: '[email protected]',
firstName: 'iradukunda',
lastName: 'benjamin',
deleted_at: false
deleted_at: false,
cycle_id: cycle._id

},
{
email: '[email protected]',
firstName: 'carlos',
lastName: 'Bz',
deleted_at: false
deleted_at: false,
cycle_id: cycle._id

},
{
email: '[email protected]',
firstName: 'blaise',
lastName: 'k',
deleted_at: false
deleted_at: false,
cycle_id: cycle._id

},
];
Expand Down
4 changes: 2 additions & 2 deletions src/seeders/applicationcycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const seedApplicationCycle = async () => {

const application = [
{
name: 'cohort 1',
name: 'Cycle 1',
startDate: '10 dec 2020',
endDate: '21 oct 2098',
},
{
name: 'cohort 2',
name: 'Cycle 2',
startDate: '01 jan 2023',
endDate: '30 jun 3042',

Expand Down
35 changes: 35 additions & 0 deletions src/seeders/cohorts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { cohortModels } from "../models/cohortModel";
import { ProgramModel } from "../models/programModel";
import { applicationCycle } from "../models/applicationCycle";

const seedCohorts = async () => {
const program = await ProgramModel.findOne();
const cycle = await applicationCycle.findOne();

if(!program || !cycle){
return;
}
const cohorts = [
{
title: "Cohort 1",
program: program._id,
cycle: cycle._id,
phase: "Phase 1",
start: "2022-01-01",
end: "2022-12-31"
},
{
title: "Cohort 2",
program: program._id,
cycle: cycle._id,
phase: "Phase 2",
start: "2023-01-01",
end: "2023-12-31"
},
];

await cohortModels.deleteMany({});
await cohortModels.insertMany(cohorts);
}

export default seedCohorts
10 changes: 9 additions & 1 deletion src/seeders/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { connect } from '../database/db.config'

import Applicationseed from './applicationcycle'
import seedDeleteTrainee from './DelTrainee'
import seedDeleteTrainee from './DelTrainee';
import seedJobs from './jobs';
import seedPrograms from './programs';
import seedCohorts from './cohorts';
import seedUsers from './users';

connect().then(async () => {
await seedUsers();
await Applicationseed()
await seedDeleteTrainee()
await seedPrograms();
await seedCohorts();
await seedJobs();
process.exit()
})
51 changes: 51 additions & 0 deletions src/seeders/jobs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { jobModels } from "../models/jobModels";
import { ProgramModel } from "../models/programModel";
import { cohortModels } from "../models/cohortModel";
import { applicationCycle } from "../models/applicationCycle";

const seedJobs = async () => {
const program = await ProgramModel.findOne();
const cohort = await cohortModels.findOne();
const cycle = await applicationCycle.findOne();

if(!program || !cohort || !cycle){
return;
}

const jobs = [
{
title: 'Senior Software Engineer',
program: program._id,
cohort: cohort._id,
cycle: cycle._id,
link: 'https://www.linkedin.com/jobs/view/senior-software-engineer-nodejs-mongodb-5f999c06282d9c1811789615/',
description: 'You will be working on cutting-edge software solutions that enhance the productivity and efficiency of our clients.',
label: 'public'
},
{
title: 'Senior Frontend Developer',
program: program._id,
cohort: cohort._id,
cycle: cycle._id,
link: 'https://www.linkedin.com/jobs/view/senior-frontend-developer-react-nodejs-5f999c06282d9c1811789615/',
description: 'This role requires a strong background in React, Node.js, and software development best practices.',
label: 'public'
},
{
title: 'Senior Backend Developer',
program: program._id,
cohort: cohort._id,
cycle: cycle._id,
link: 'https://www.linkedin.com/jobs/view/senior-backend-developer-python-django-5f999c06282d9c1811789615/',
description: ' This role requires a strong background in Python, Django, and software development best practices.',
label: 'public'
}

]

await jobModels.deleteMany({});
await jobModels.insertMany(jobs);
return null;
}

export default seedJobs;
29 changes: 29 additions & 0 deletions src/seeders/programs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ProgramModel } from "../models/programModel";

const seedPrograms = async () => {
const programs = [
{
title: "Web Development",
description: "Learn to build websites using HTML, CSS, and JavaScript",
duration: "6 months",
deleted_at: false,
mainObjective: "Create responsive and engaging websites",
requirements: ["Basic Computer Skills"],
modeOfExecution: "Online"
},
{
title: "Mobile Application",
description: "Learn to develop mobile applications using Java or Kotlin",
duration: "4 months",
deleted_at: false,
mainObjective: "Create cross-platform applications for Android and iOS",
requirements: ["Basic Computer Skills", "Java or Kotlin"],
modeOfExecution: "Hybrid"
}
]
await ProgramModel.deleteMany({})
await ProgramModel.insertMany(programs)
return null;
}

export default seedPrograms;
34 changes: 34 additions & 0 deletions src/seeders/users.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { LoggedUserModel } from "../models/AuthUser";
import { RoleModel } from "../models/roleModel";
import BcryptUtil from "../utils/bcrypt";

// Seed users with superAdmin role.
const seedUsers = async() => {
const superAdminRole = await RoleModel.findOne({ roleName: 'superAdmin' });
const applicantRole = await RoleModel.findOne({ roleName: 'applicant' });

if(!superAdminRole || !applicantRole){
return;
}

const users = [
{
firstname: "Super",
lastname: "Admin",
email: "[email protected]",
password: await BcryptUtil.hash("password123"),
role: superAdminRole._id,
country: "Rwanda",
code: "+250",
telephone: "0788888888",
isActive: true,
gender: "female",

}
]

await LoggedUserModel.insertMany(users);

}

export default seedUsers;