-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b2046e
commit 6233d2b
Showing
15 changed files
with
559 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
PORT=4000 | ||
TOKEN_SECRET=mysecret | ||
ENVIRONMENT=local | ||
DB_URL=mongodb://mongo1:30001,mongo2:30002,mongo3:30003/?replicaSet=my-replica-set | ||
EMAIL_HOST= | ||
EMAIL_PORT= | ||
EMAIL_USER= | ||
EMAIL_PASS= | ||
|
||
# get email stuff from mailtrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,4 +130,5 @@ dist | |
.pnp.* | ||
|
||
# ingore genrated APIdocs | ||
apidoc | ||
apidoc | ||
data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { faker } from "@faker-js/faker"; // eslint-disable-line import/no-extraneous-dependencies | ||
|
||
const createRandomAttendance = (studentId, courseId) => { | ||
const monthlyAttendedInt = faker.number.int({ min: 0, max: 25 }); | ||
return { | ||
student: studentId, | ||
course: courseId, | ||
monthlyAttended: monthlyAttendedInt, | ||
monthlyOccured: faker.number.int({ min: 25, max: 27 }), | ||
cumulativeAttended: | ||
monthlyAttendedInt + faker.number.int({ min: 0, max: 150 }), | ||
cumulativeOccured: | ||
monthlyAttendedInt + faker.number.int({ min: 150, max: 175 }), | ||
}; | ||
}; | ||
|
||
const generateAttendance = (studentCourseList) => { | ||
const attendance = []; | ||
for (let i = 0, j = 0; i < studentCourseList.length; j += 1) { | ||
attendance.push( | ||
createRandomAttendance( | ||
studentCourseList[i].studentId, | ||
studentCourseList[i].coursesOpted[j], | ||
), | ||
); | ||
if (j >= 6) { | ||
i += 1; | ||
j = 0; | ||
} | ||
} | ||
return attendance; | ||
}; | ||
|
||
export default generateAttendance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { faker } from "@faker-js/faker"; // eslint-disable-line import/no-extraneous-dependencies | ||
|
||
function getRandomLetter() { | ||
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | ||
const randomIndex = Math.floor(Math.random() * alphabet.length); | ||
return alphabet[randomIndex]; | ||
} | ||
|
||
function randomDate(start, end) { | ||
return new Date( | ||
start.getTime() + Math.random() * (end.getTime() - start.getTime()), | ||
); | ||
} | ||
|
||
// Function to generate random 4-digit number | ||
function getRandomNumber() { | ||
return Math.floor(1000 + Math.random() * 9000); | ||
} | ||
|
||
const generatedIDs = []; | ||
|
||
const createRandomFaculty = (departmentId, createdCourses) => { | ||
let id; | ||
do { | ||
const letter = getRandomLetter(); | ||
const number = getRandomNumber(); | ||
id = `F${letter}${number}`; | ||
} while (generatedIDs.includes(id)); | ||
generatedIDs.push(id); | ||
const doj = faker.date.past({ years: 5 }); | ||
return { | ||
ERPID: id, | ||
dateOfJoining: doj, | ||
dateOfLeaving: faker.datatype.boolean({ probability: 0.4 }) | ||
? randomDate(doj, new Date()) | ||
: null, | ||
profileLink: faker.internet.url(), | ||
qualifications: [ | ||
faker.lorem.word(), | ||
faker.lorem.word(), | ||
faker.lorem.word(), | ||
], | ||
totalExperience: faker.number.int({ min: 1, max: 20 }), | ||
achievements: [ | ||
faker.lorem.words(), | ||
faker.lorem.words(), | ||
faker.lorem.words(), | ||
], | ||
areaOfSpecialization: [ | ||
faker.lorem.word(), | ||
faker.lorem.word(), | ||
faker.lorem.word(), | ||
], | ||
papersPublishedPG: faker.number.int({ min: 0, max: 50 }), | ||
papersPublishedUG: faker.number.int({ min: 0, max: 50 }), | ||
department: departmentId, | ||
preferredSubjects: createdCourses, | ||
designation: faker.helpers.arrayElements( | ||
[ | ||
"HOD", | ||
"Assistant Professor", | ||
"Associate Professor", | ||
"Activity Head", | ||
"Professor", | ||
"Director", | ||
"T&P Officer", | ||
"R&D Activity Head", | ||
], | ||
{ min: 1, max: 3 }, | ||
), | ||
natureOfAssociation: faker.helpers.arrayElement([ | ||
"Regular", | ||
"Contract", | ||
"Adjunct", | ||
]), | ||
additionalResponsibilities: faker.lorem.words(), | ||
}; | ||
}; | ||
|
||
const generateFaculty = (createdDepts, createdCourses) => { | ||
const faculty = []; | ||
let selectedCourses; | ||
for (let i = 0, j = 1; i < createdDepts.length; j += 1) { | ||
selectedCourses = faker.helpers.arrayElements(createdCourses, { | ||
min: 4, | ||
max: 8, | ||
}); | ||
faculty.push(createRandomFaculty(createdDepts[i], selectedCourses)); | ||
if (j > 30) { | ||
i += 1; | ||
j = 0; | ||
} | ||
} | ||
return faculty; | ||
}; | ||
|
||
export default generateFaculty; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { faker } from "@faker-js/faker"; // eslint-disable-line import/no-extraneous-dependencies | ||
|
||
const generateNotifications = (studentIds, facultyIds, adminIds) => { | ||
const notifications = []; | ||
const notificationTypes = ["Student", "Faculty"]; | ||
|
||
for (let i = 0; i < 300; i += 1) { | ||
const notification = { | ||
data: faker.lorem.lines({ min: 3, max: 7 }), | ||
title: faker.lorem.sentence(), | ||
from: faker.helpers.arrayElement([...facultyIds, ...adminIds]), | ||
type: faker.helpers.arrayElement(notificationTypes), | ||
filter: [], | ||
}; | ||
|
||
if (notification.type === "Student") { | ||
notification.filter = faker.helpers.arrayElements(studentIds, { | ||
min: 5, | ||
max: 100, | ||
}); | ||
} else { | ||
notification.filter = faker.helpers.arrayElements( | ||
[...facultyIds, ...adminIds], | ||
{ min: 5, max: 100 }, | ||
); | ||
} | ||
notifications.push(notification); | ||
} | ||
|
||
return notifications; | ||
}; | ||
|
||
export default generateNotifications; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { faker } from "@faker-js/faker"; // eslint-disable-line import/no-extraneous-dependencies | ||
|
||
const departmentAbbrev = [ | ||
"ME", | ||
"CE", | ||
"CS", | ||
"IT", | ||
"ETE", | ||
"ECS", | ||
"AIDS", | ||
"IOT", | ||
"AIML", | ||
"CSS", | ||
"MEMM", | ||
"AIDS", | ||
"SD", | ||
"AGD", | ||
"DA", | ||
]; | ||
|
||
function generateRandomYear() { | ||
const currentYear = new Date().getFullYear(); | ||
const availableYears = Array.from( | ||
{ length: 4 }, | ||
(_, index) => currentYear - index, | ||
); | ||
const randomIndex = Math.floor(Math.random() * availableYears.length); | ||
return availableYears[randomIndex].toString().slice(-2); | ||
} | ||
|
||
function generateRandomThreeDigitNumber() { | ||
return Math.floor(100 + Math.random() * 900); | ||
} | ||
|
||
function generateStudentID(i) { | ||
const departmentInitials = departmentAbbrev[i]; | ||
const year = generateRandomYear(); | ||
const randomThreeDigitNumber = generateRandomThreeDigitNumber(); | ||
return `S${departmentInitials}${year}${randomThreeDigitNumber}`; | ||
} | ||
|
||
const generatedIDs = []; | ||
|
||
const createRandomStudent = (department, createdCourses, k, j, i) => { | ||
let id; | ||
let divisionLetter; | ||
do id = generateStudentID(i); | ||
while (generatedIDs.includes(id)); | ||
generatedIDs.push(id); | ||
if (j >= 120) divisionLetter = "C"; | ||
else if (j >= 60) divisionLetter = "B"; | ||
else divisionLetter = "A"; | ||
return { | ||
ERPID: id, | ||
name: faker.person.fullName(), | ||
joiningYear: new Date().getFullYear() - k, | ||
branch: department, | ||
division: divisionLetter, | ||
rollNo: (j % 60) + 1, | ||
coursesOpted: createdCourses, | ||
}; | ||
}; | ||
|
||
const generateStudents = (createdDepts, createdCourses) => { | ||
const students = []; | ||
let selectedCourses; | ||
for (let i = 0, j = 0, k = 0; k < 4; j += 1) { | ||
selectedCourses = faker.helpers.arrayElements(createdCourses, 7); | ||
students.push( | ||
createRandomStudent(createdDepts[i], selectedCourses, k, j, i), | ||
); | ||
if (j >= 179) { | ||
i += 1; | ||
j = -1; | ||
} | ||
if (i === createdDepts.length) { | ||
i = 0; | ||
k += 1; | ||
} | ||
} | ||
return students; | ||
}; | ||
|
||
export default generateStudents; |
Oops, something went wrong.