@@ -9,6 +9,11 @@ import Tutorial from "#models/tutorial";
99import Practical from "#models/practical" ;
1010import Semester from "#models/semester" ;
1111import Course from "#models/course" ;
12+ import Faculty from "#models/faculty" ;
13+ import Student from "#models/student" ;
14+ import Attendance from "#models/attendance" ;
15+ import Notification from "#models/notification" ;
16+ import User from "#models/user" ;
1217import generateOrganizations from "#mockDB/orgMock" ;
1318import ACCREDS from "#mockDB/accredMock" ;
1419import TOPICS from "#mockDB/topicMock" ;
@@ -19,6 +24,11 @@ import generatePracticals from "#mockDB/pracMock";
1924import generateTutorials from "#mockDB/tutMock" ;
2025import generateSemesters from "#mockDB/semMock" ;
2126import generateCourses from "#mockDB/courseMock" ;
27+ import generateFaculty from "#mockDB/facultyMock" ;
28+ import generateStudents from "#mockDB/studentMock" ;
29+ import generateAttendance from "#mockDB/attendanceMock" ;
30+ import generateNotifications from "#mockDB/notificationMock" ;
31+ import generateUsers from "#mockDB/userMock" ; // eslint-disable-line no-unused-vars
2232/* eslint-disable no-underscore-dangle */
2333const createdAccreds = await Accreditation . createMultiple ( ACCREDS ) ;
2434
@@ -86,6 +96,59 @@ const COURSES = generateCourses(
8696 createdDepts . map ( ( createdDept ) => createdDept . _id ) ,
8797) ;
8898
89- const createdCourses = await Course . createMultiple ( COURSES ) ; // eslint-disable-line no-unused-vars
99+ const createdCourses = await Course . createMultiple ( COURSES ) ;
100+
101+ const FACULTY = generateFaculty (
102+ createdDepts . map ( ( createdDept ) => createdDept . _id ) ,
103+ createdCourses . map ( ( createdCourse ) => createdCourse . _id ) ,
104+ ) ;
105+
106+ const createdFaculty = await Faculty . createMultiple ( FACULTY ) ;
107+
108+ const STUDENTS = generateStudents (
109+ createdDepts . map ( ( createdDept ) => createdDept . _id ) ,
110+ createdCourses . map ( ( createdCourse ) => createdCourse . _id ) ,
111+ ) ;
112+
113+ const createdStudents = await Student . createMultiple ( STUDENTS ) ;
114+
115+ const studentCourseList = createdStudents . map ( ( student ) => {
116+ const studentId = student . _id . toString ( ) ;
117+ const coursesOpted = student . coursesOpted . map ( ( courseId ) =>
118+ courseId . toString ( ) ,
119+ ) ;
120+ return { studentId, coursesOpted } ;
121+ } ) ;
122+
123+ const ATTENDANCE = generateAttendance ( studentCourseList ) ;
124+
125+ const createdAttendance = await Attendance . createMultiple ( ATTENDANCE ) ;
126+
127+ // const USERS = generateUsers( // TODO this takes forever bruhh
128+ // createdStudents.map((createdStudent) => createdStudent.ERPID),
129+ // createdFaculty.map((createdFaculty) => createdFaculty.ERPID),
130+ // )
131+
132+ // const createdUsers = await User.createMultiple(USERS)
133+
134+ const createdUsers = await User . read ( ) ; // use this after you initialized Users at least once, or wait for years every time
135+
136+ const NOTIFS = generateNotifications (
137+ createdUsers . data
138+ . filter ( ( user ) => user . userType === "STUDENT" )
139+ . map ( ( student ) => student . _id ) ,
140+ createdUsers . data
141+ . filter ( ( user ) => user . userType === "FACULTY" )
142+ . map ( ( faculty ) => faculty . _id ) ,
143+ createdUsers . data
144+ . filter ( ( user ) => user . userType === "ADMIN" )
145+ . map ( ( admin ) => admin . _id ) ,
146+ ) ;
147+
148+ const createdNotifications = await Notification . createMultiple ( NOTIFS ) ;
149+
150+ console . log ( createdNotifications ) ;
151+ console . log ( createdAttendance ) ;
152+ console . log ( createdFaculty ) ;
90153
91154process . exit ( 0 ) ;
0 commit comments