lms-sync 1.0.47 → 1.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apiConnections/mapping.js +379 -604
- package/models/employees.model.js +393 -0
- package/package.json +1 -1
@@ -19,7 +19,8 @@ const {
|
|
19
19
|
Subjects,
|
20
20
|
Schedules,
|
21
21
|
Users,
|
22
|
-
Semesters
|
22
|
+
Semesters,
|
23
|
+
Employees,
|
23
24
|
|
24
25
|
} = db
|
25
26
|
|
@@ -29,7 +30,7 @@ const server = {
|
|
29
30
|
try {
|
30
31
|
console.log("");
|
31
32
|
console.log("########################################################")
|
32
|
-
console.log("
|
33
|
+
console.log(" Campuses Migration ")
|
33
34
|
console.log("########################################################")
|
34
35
|
console.log("");
|
35
36
|
|
@@ -66,9 +67,9 @@ const server = {
|
|
66
67
|
defaults: userDefPayload
|
67
68
|
});
|
68
69
|
|
69
|
-
if (createdUser){
|
70
|
-
|
71
|
-
}
|
70
|
+
// if (createdUser){
|
71
|
+
// logger.info(`Created Migration User :>> ${userDefault.email}`);
|
72
|
+
// }
|
72
73
|
|
73
74
|
const userMail = await Users.findOne({ where: { email: 'ccci_integrator@gmail.com' } });
|
74
75
|
|
@@ -199,7 +200,7 @@ const server = {
|
|
199
200
|
}
|
200
201
|
}
|
201
202
|
|
202
|
-
// bulk create new campus
|
203
|
+
// bulk create new campus Records
|
203
204
|
if (newCampus.length > 0) {
|
204
205
|
await Campuses.bulkCreate(newCampus)
|
205
206
|
createdCounter += newCampus.length
|
@@ -213,9 +214,9 @@ const server = {
|
|
213
214
|
console.log("########################################################")
|
214
215
|
console.log("")
|
215
216
|
logger.info('Campus Data Migration Completed');
|
216
|
-
logger.info(`Total
|
217
|
-
logger.info(`Total Campus
|
218
|
-
logger.info(`Total
|
217
|
+
logger.info(`Total Successful Campus Records Created: ${createdCounter}/${createdCounter}`);
|
218
|
+
logger.info(`Total Existing Campus Records: ${errorCounter}/${errorCounter}`);
|
219
|
+
logger.info(`Total Records: ${createdCounter + errorCounter}`);
|
219
220
|
console.log("")
|
220
221
|
console.log("########################################################")
|
221
222
|
console.log("")
|
@@ -342,7 +343,7 @@ const server = {
|
|
342
343
|
}
|
343
344
|
}
|
344
345
|
|
345
|
-
// bulk create new campus
|
346
|
+
// bulk create new campus Records
|
346
347
|
if (newColleges.length > 0) {
|
347
348
|
await Colleges.bulkCreate(newColleges)
|
348
349
|
createdCounter += newColleges.length
|
@@ -358,9 +359,9 @@ const server = {
|
|
358
359
|
console.log("########################################################")
|
359
360
|
console.log("")
|
360
361
|
logger.info('College Data Migration Completed');
|
361
|
-
logger.info(`Total
|
362
|
-
logger.info(`Total College
|
363
|
-
logger.info(`Total
|
362
|
+
logger.info(`Total Successful College Records Created: ${createdCounter}/${createdCounter}`);
|
363
|
+
logger.info(`Total Existing College Records: ${errorCounter}/${errorCounter}`);
|
364
|
+
logger.info(`Total Records: ${itemLength}`)
|
364
365
|
console.log("")
|
365
366
|
console.log("########################################################")
|
366
367
|
console.log("")
|
@@ -572,9 +573,9 @@ const server = {
|
|
572
573
|
console.log("########################################################")
|
573
574
|
console.log("")
|
574
575
|
logger.info('Academic Department Data Migration Completed');
|
575
|
-
logger.info(`Total
|
576
|
-
logger.info(`Total Academic Department
|
577
|
-
logger.info(`Total
|
576
|
+
logger.info(`Total Successful Academic Department Records Created: ${createdCounter}/${createdCounter}`);
|
577
|
+
logger.info(`Total Existing Academic Department Records: ${errorCounter}/${errorCounter}`);
|
578
|
+
logger.info(`Total Records: ${createdCounter + errorCounter}`);
|
578
579
|
console.log("")
|
579
580
|
console.log("########################################################")
|
580
581
|
console.log("")
|
@@ -601,7 +602,6 @@ const server = {
|
|
601
602
|
console.log("########################################################")
|
602
603
|
console.log("");
|
603
604
|
|
604
|
-
|
605
605
|
const db_schema = schema
|
606
606
|
let maxIds = await Users.max('_id'); //Fetch maximum _id directly from the Users model
|
607
607
|
let maxIdsIns = await Instructors.max('_id'); //Fetch maximum _id directly from the Users model
|
@@ -620,6 +620,8 @@ const server = {
|
|
620
620
|
|
621
621
|
const departmentSeq = await AcademicDepartments.findAll()
|
622
622
|
const campusSeq = await Campuses.findAll()
|
623
|
+
const employeeSeq = await Employees.findAll()
|
624
|
+
const userSeq = await Users.findAll()
|
623
625
|
|
624
626
|
const userMail = await Users.findOne({ where: { email: 'ccci_integrator@gmail.com' } });
|
625
627
|
if (!userMail){}
|
@@ -679,6 +681,15 @@ const server = {
|
|
679
681
|
let acadDepartmentMap = departmentApi.find(a => a.name === _instructor?.department_name)
|
680
682
|
let _acadDepartment = departmentSeq.find(b => b.name === acadDepartmentMap?.name)
|
681
683
|
let campusMap = campusSeq.find(c => c._id === _acadDepartment?.campusId)
|
684
|
+
|
685
|
+
let employeeFind = employeeSeq.find(emps => emps.employeeNumber === _instructor?.faculty_id)
|
686
|
+
let userFind = userSeq.find(eus => eus._id === employeeFind?.userId)
|
687
|
+
let _userFind = userSeq.find(e => e.firstName === _instructor?.first_name && e.middleName === _instructor?.middle_name && e.lastName === _instructor?.last_name)
|
688
|
+
|
689
|
+
// console.log('userFind :>> ', userFind);
|
690
|
+
|
691
|
+
if(!employeeFind){}
|
692
|
+
if(!userFind){}
|
682
693
|
|
683
694
|
let modifiedById = userMail?._id
|
684
695
|
let createdById = userMail?._id
|
@@ -714,6 +725,10 @@ const server = {
|
|
714
725
|
let employeeNumber = _instructor?.faculty_id
|
715
726
|
let departmentId = _acadDepartment?._id??departmentDefault?._id
|
716
727
|
let campusId = campusMap?._id??_campusDefault?._id
|
728
|
+
let employeeId = employeeFind?._id??null
|
729
|
+
let userId = userFind?._id??_userFind?._id
|
730
|
+
|
731
|
+
// console.log('userId :>> ', userId);
|
717
732
|
|
718
733
|
if(uEmail.has(email) && uPass.has(password) && uTPass.has(temporaryPassword) && uULname.has(lastName) && uUFname.has(firstName) && uUMname.has(middleName) && uScopes.has(adminScopes)){
|
719
734
|
const errorMsg = `Duplicate Payload Found: [${email} - ${password} ${temporaryPassword}] - ${lastName}, ${firstName} ${middleName} ${adminScopes}`
|
@@ -792,7 +807,9 @@ const server = {
|
|
792
807
|
migratedAt,
|
793
808
|
migratedTable,
|
794
809
|
// referenceId,
|
795
|
-
isMigrated
|
810
|
+
isMigrated,
|
811
|
+
userId: userId || null,
|
812
|
+
employeeId,
|
796
813
|
})
|
797
814
|
}
|
798
815
|
|
@@ -813,11 +830,12 @@ const server = {
|
|
813
830
|
|
814
831
|
if (newInstructor.length > 0) {
|
815
832
|
// Associate userIds with new instructors
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
833
|
+
// if(!newInstructor.userId){
|
834
|
+
// newInstructor = newInstructor.map((inst, index) => ({
|
835
|
+
// ...inst,
|
836
|
+
// userId: userIds[index]
|
837
|
+
// }));
|
838
|
+
// }
|
821
839
|
await Instructors.bulkCreate(newInstructor);
|
822
840
|
createdCounter += newInstructor.length;
|
823
841
|
|
@@ -825,27 +843,16 @@ const server = {
|
|
825
843
|
logger.info(`${index + 1}/${index + 1}: New Instructor Record Created: [${inst.employeeNumber}] - ${inst.lastName}, ${inst.firstName} ${inst.middleName} [ departmentId: ${inst.departmentId}, campusId: ${inst.campusId}]`);
|
826
844
|
});
|
827
845
|
}
|
828
|
-
|
829
|
-
|
830
|
-
// if (newInstructor.length > 0) {
|
831
|
-
|
832
|
-
// await Instructors.bulkCreate(newInstructor)
|
833
|
-
// createdCounter += newInstructor.length
|
834
|
-
|
835
|
-
// newInstructor.forEach((inst, index) => {
|
836
|
-
// logger.info(`${index + 1}/${index + 1}: New Instructor Record Created: [${inst.employeeNumber}] - ${inst.lastName}, ${inst.firstName} ${inst.middleName} [ departmentId: ${inst.departmentId}, campusId: ${inst.campusId}]`)
|
837
|
-
// });
|
838
|
-
|
839
|
-
// }
|
846
|
+
|
840
847
|
|
841
848
|
|
842
849
|
console.log("");
|
843
850
|
console.log("########################################################")
|
844
851
|
console.log("")
|
845
|
-
logger.info('
|
846
|
-
logger.info(`Total
|
847
|
-
logger.info(`Total
|
848
|
-
logger.info(`Total
|
852
|
+
logger.info('Instructors Data Migration Completed');
|
853
|
+
logger.info(`Total Successful Instructors Records Created: ${createdCounter}/${createdCounter}`);
|
854
|
+
logger.info(`Total Existing Instructors Records: ${errorCounter}/${errorCounter}`);
|
855
|
+
logger.info(`Total Records: ${createdCounter + errorCounter}`);
|
849
856
|
|
850
857
|
console.log("")
|
851
858
|
console.log("########################################################")
|
@@ -865,182 +872,182 @@ const server = {
|
|
865
872
|
}
|
866
873
|
},
|
867
874
|
|
868
|
-
async Instructorsss(){
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
875
|
+
// async Instructorsss(){
|
876
|
+
// try {
|
877
|
+
// console.log("");
|
878
|
+
// console.log("########################################################")
|
879
|
+
// console.log(" Instructors Migration ")
|
880
|
+
// console.log("########################################################")
|
881
|
+
// console.log("");
|
882
|
+
|
883
|
+
// const db_schema = schema
|
884
|
+
// let maxIds = await Instructors.max('_id'); //Fetch maximum _id directly from the Instructors model
|
885
|
+
// let maxId = maxIds|| 0;
|
886
|
+
// await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."Instructors__id_seq"`);
|
887
|
+
// await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Instructors__id_seq" RESTART WITH ${maxId + 1}`);
|
888
|
+
|
889
|
+
// const instructorApi = await api.Instructor()
|
890
|
+
// const departmentApi = await api.Department()
|
891
|
+
|
892
|
+
// const departmentSeq = await AcademicDepartments.findAll()
|
893
|
+
// const campusSeq = await Campuses.findAll()
|
894
|
+
// const userSeq = await Users.findAll()
|
895
|
+
|
896
|
+
// const userMail = await Users.findOne({ where: { email: 'ccci_integrator@gmail.com' } });
|
897
|
+
// if (!userMail){}
|
898
|
+
// const campusDefault = await Campuses.findOne({ where: { name: 'Campus Default' } });
|
899
|
+
// const departmentDefault = await AcademicDepartments.findOne({ where: { name: 'AcademicDepartments Default' } });
|
893
900
|
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
901
|
+
// let defaultPayload = {
|
902
|
+
// firstName: 'Instructor',
|
903
|
+
// lastName: 'Default',
|
904
|
+
// middleName: 'Migration',
|
905
|
+
// employeeNumber: '_Instructor',
|
906
|
+
// departmentId: departmentDefault?._id,
|
907
|
+
// campusId: campusDefault?._id,
|
908
|
+
// modifiedById: userMail?._id,
|
909
|
+
// createdById: userMail?._id
|
910
|
+
// };
|
904
911
|
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
912
|
+
// let [defaults, createddef] = await Instructors.findOrCreate({
|
913
|
+
// where: { employeeNumber: defaultPayload.employeeNumber, lastName: defaultPayload.lastName},
|
914
|
+
// defaults: defaultPayload
|
915
|
+
// });
|
909
916
|
|
910
|
-
|
911
|
-
|
912
|
-
|
917
|
+
// let createdCounter = 0
|
918
|
+
// let errorCounter = 0
|
919
|
+
// let uniqueErrors = new Set()
|
913
920
|
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
921
|
+
// let uDept = new Set()
|
922
|
+
// let uCamp = new Set()
|
923
|
+
// let uLname = new Set()
|
924
|
+
// let uMname = new Set()
|
925
|
+
// let uFname = new Set()
|
926
|
+
// let uNum = new Set()
|
920
927
|
|
921
|
-
|
928
|
+
// let newInstructor = []
|
922
929
|
|
923
|
-
|
924
|
-
|
930
|
+
// const exInst = await Instructors.findAll()
|
931
|
+
// const exInstMap = new Map(exInst.map(inst => [`[${inst.employeeNumber}] - ${inst.lastName}, ${inst.firstName} ${inst.middleName} [${inst.departmentId}, ${inst.campusId}]` , inst]))
|
925
932
|
|
926
933
|
|
927
|
-
|
928
|
-
|
934
|
+
// for (let i = 0; i < instructorApi.length; i++){
|
935
|
+
// try {
|
929
936
|
|
930
|
-
|
937
|
+
// let _instructor = instructorApi[i]
|
931
938
|
|
932
|
-
|
939
|
+
// let findUser = await userSeq.find( f => f.lastName === _instructor?.last_name && f.firstName === _instructor?.first_name && f.middleName === _instructor?.middle_name)
|
933
940
|
|
934
|
-
|
935
|
-
|
936
|
-
|
941
|
+
// let acadDepartmentMap = departmentApi.find(a => a.name === _instructor?.department_name)
|
942
|
+
// let _acadDepartment = departmentSeq.find(b => b.name === acadDepartmentMap?.name)
|
943
|
+
// let campusMap = campusSeq.find(c => c._id === _acadDepartment?.campusId)
|
937
944
|
|
938
|
-
|
939
|
-
|
945
|
+
// let modifiedById = userMail?._id
|
946
|
+
// let createdById = userMail?._id
|
940
947
|
|
941
|
-
|
942
|
-
|
948
|
+
// let campusDefault = "MSC - Boac Campus"
|
949
|
+
// let _campusDefault = campusSeq.find(ccc => ccc.name === campusDefault)
|
943
950
|
|
944
|
-
|
945
|
-
|
946
|
-
|
951
|
+
// let role = _instructor?.role
|
952
|
+
// let isChairPerson = false
|
953
|
+
// let isDean = false
|
947
954
|
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
955
|
+
// if(role === "Program Chair"){
|
956
|
+
// isChairPerson = true
|
957
|
+
// }
|
958
|
+
// if(role === "Dean"){
|
959
|
+
// isDean = true
|
960
|
+
// }
|
954
961
|
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
962
|
+
// let firstName = _instructor?.first_name
|
963
|
+
// let lastName = _instructor?.last_name
|
964
|
+
// let middleName = _instructor?.middle_name
|
965
|
+
// let employeeNumber = _instructor?.faculty_id
|
966
|
+
// let departmentId = _acadDepartment?._id??departmentDefault?._id
|
967
|
+
// let campusId = campusMap?._id??_campusDefault?._id
|
968
|
+
// let userId = findUser?._id
|
969
|
+
|
970
|
+
// if(uNum.has(employeeNumber) && uLname.has(lastName) && uFname.has(firstName) && uMname.has(middleName) && uDept.has(departmentId) && uCamp.has(campusId)){
|
971
|
+
// const errorMsg = `Duplicate Payload Found: [${employeeNumber}] - ${lastName}, ${firstName} ${middleName} [departmentId: ${departmentId}, campusId:${campusId}]`
|
972
|
+
// if(!uniqueErrors.has(errorMsg)){
|
973
|
+
// logger.error(`${errorCounter + 1}/${errorCounter + 1}: ${errorMsg}`)
|
974
|
+
// uniqueErrors.add(errorMsg)
|
975
|
+
// errorCounter++
|
976
|
+
// }
|
977
|
+
// }
|
978
|
+
// else if ( exInstMap.has(`[${employeeNumber}] - ${lastName}, ${firstName} ${middleName} [${departmentId}, ${campusId}]`)){
|
979
|
+
// const exInst = exInstMap.get(`[${employeeNumber}] - ${lastName}, ${firstName} ${middleName} [${departmentId}, ${campusId}]`)
|
980
|
+
// const errorMsg = `Existing Data Found:[${exInst.employeeNumber}] - ${exInst.lastName}, ${exInst.firstName} ${exInst.middleName} [departmentId: ${exInst.departmentId}, campusId: ${exInst.campusId}]`
|
981
|
+
// if(!uniqueErrors.has(errorMsg)){
|
982
|
+
// logger.error(`${errorCounter + 1}/${errorCounter + 1}: ${errorMsg}`)
|
983
|
+
// uniqueErrors.add(errorMsg)
|
984
|
+
// errorCounter++
|
985
|
+
// }
|
986
|
+
// }
|
987
|
+
// else{
|
988
|
+
// uNum.add(employeeNumber)
|
989
|
+
// uLname.add(lastName)
|
990
|
+
// uFname.add(firstName)
|
991
|
+
// uMname.add(middleName)
|
992
|
+
// uDept.add(departmentId)
|
993
|
+
// uCamp.add(campusId)
|
994
|
+
// newInstructor.push({
|
995
|
+
// firstName: _instructor?.first_name,
|
996
|
+
// lastName: _instructor?.last_name,
|
997
|
+
// middleName: _instructor?.middle_name,
|
998
|
+
// employeeNumber: _instructor?.faculty_id,
|
999
|
+
// departmentId: _acadDepartment?._id??departmentDefault?._id,
|
1000
|
+
// academicDepartmentId: _acadDepartment?._id??departmentDefault?._id,
|
1001
|
+
// campusId: campusMap?._id??_campusDefault?._id??campusDefault?._id,
|
1002
|
+
// isDean,
|
1003
|
+
// isChairPerson,
|
1004
|
+
// modifiedById,
|
1005
|
+
// createdById,
|
1006
|
+
// userId
|
1007
|
+
// })
|
1008
|
+
// }
|
1002
1009
|
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1010
|
+
// } catch (error) {
|
1011
|
+
// logger.error(`Error occurred: ${error} ${error.stack}`);
|
1012
|
+
// }
|
1013
|
+
// }
|
1007
1014
|
|
1008
|
-
|
1015
|
+
// if (newInstructor.length > 0) {
|
1009
1016
|
|
1010
|
-
|
1011
|
-
|
1017
|
+
// await Instructors.bulkCreate(newInstructor)
|
1018
|
+
// createdCounter += newInstructor.length
|
1012
1019
|
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1020
|
+
// newInstructor.forEach((inst, index) => {
|
1021
|
+
// logger.info(`${index + 1}/${index + 1}: New Instructor Record Created: [${inst.employeeNumber}] - ${inst.lastName}, ${inst.firstName} ${inst.middleName} [ departmentId: ${inst.departmentId}, campusId: ${inst.campusId}]`)
|
1022
|
+
// });
|
1023
|
+
|
1024
|
+
// }
|
1025
|
+
|
1026
|
+
// console.log("");
|
1027
|
+
// console.log("########################################################")
|
1028
|
+
// console.log("")
|
1029
|
+
// logger.info('Instructors Data Migration Completed');
|
1030
|
+
// logger.info(`Total Successful Instructors Records Created: ${createdCounter}/${createdCounter}`);
|
1031
|
+
// logger.info(`Total Existing Instructors Records: ${errorCounter}/${errorCounter}`);
|
1032
|
+
// logger.info(`Total Records: ${createdCounter + errorCounter}`);
|
1033
|
+
|
1034
|
+
// console.log("")
|
1035
|
+
// console.log("########################################################")
|
1036
|
+
// console.log("")
|
1037
|
+
|
1038
|
+
// let totalSummary = {
|
1039
|
+
// itemLength: createdCounter + errorCounter,
|
1040
|
+
// error: errorCounter,
|
1041
|
+
// success: createdCounter
|
1042
|
+
// }
|
1043
|
+
// return totalSummary
|
1044
|
+
|
1045
|
+
// } catch (error) {
|
1046
|
+
// ;
|
1047
|
+
// logger.error(`Error occurred: ${error} ${error.stack} `);
|
1041
1048
|
|
1042
|
-
|
1043
|
-
},
|
1049
|
+
// }
|
1050
|
+
// },
|
1044
1051
|
|
1045
1052
|
async Course(){
|
1046
1053
|
try {
|
@@ -1185,8 +1192,8 @@ const server = {
|
|
1185
1192
|
console.log("########################################################")
|
1186
1193
|
console.log("")
|
1187
1194
|
logger.info('Course Data Migration Completed');
|
1188
|
-
logger.info(`Total
|
1189
|
-
logger.info(`Total Course
|
1195
|
+
logger.info(`Total Successful Course Records Created: ${createdCounter}/${createdCounter}`);
|
1196
|
+
logger.info(`Total Existing Course Records: ${errorCounter}/${errorCounter}`);
|
1190
1197
|
console.log("")
|
1191
1198
|
console.log("########################################################")
|
1192
1199
|
console.log("")
|
@@ -1335,9 +1342,9 @@ const server = {
|
|
1335
1342
|
console.log("########################################################")
|
1336
1343
|
console.log("")
|
1337
1344
|
logger.info('Room Data Migration Completed');
|
1338
|
-
logger.info(`Total
|
1339
|
-
logger.info(`Total Room
|
1340
|
-
logger.info(`Total
|
1345
|
+
logger.info(`Total Successful Room Records Created: ${createdCounter}/${createdCounter}`);
|
1346
|
+
logger.info(`Total Existing Room Records: ${errorCounter}/${errorCounter}`);
|
1347
|
+
logger.info(`Total Records: ${createdCounter + errorCounter}`);
|
1341
1348
|
console.log("")
|
1342
1349
|
console.log("########################################################")
|
1343
1350
|
console.log("")
|
@@ -1466,9 +1473,9 @@ const server = {
|
|
1466
1473
|
console.log("########################################################")
|
1467
1474
|
console.log("")
|
1468
1475
|
logger.info('Academic Years Data Migration Completed');
|
1469
|
-
logger.info(`Total
|
1470
|
-
logger.info(`Total Academic Years
|
1471
|
-
logger.info(`Total
|
1476
|
+
logger.info(`Total Successful Academic Years Records Created: ${createdCounter}/${createdCounter}`);
|
1477
|
+
logger.info(`Total Existing Academic Years Records: ${errorCounter}/${errorCounter}`);
|
1478
|
+
logger.info(`Total Records: ${createdCounter + errorCounter}`);
|
1472
1479
|
console.log("")
|
1473
1480
|
console.log("########################################################")
|
1474
1481
|
console.log("")
|
@@ -1637,8 +1644,8 @@ const server = {
|
|
1637
1644
|
console.log("########################################################")
|
1638
1645
|
console.log("")
|
1639
1646
|
logger.info('Subjects Data Migration Completed');
|
1640
|
-
logger.info(`Total
|
1641
|
-
logger.info(`Total Subjects
|
1647
|
+
logger.info(`Total Successful Subjects Records Created: ${createdCounter}/${createdCounter}`);
|
1648
|
+
logger.info(`Total Existing Subjects Records: ${errorCounter}/${errorCounter}`);
|
1642
1649
|
console.log("")
|
1643
1650
|
console.log("########################################################")
|
1644
1651
|
console.log("")
|
@@ -1659,6 +1666,9 @@ const server = {
|
|
1659
1666
|
|
1660
1667
|
async Schedule(){
|
1661
1668
|
try {
|
1669
|
+
|
1670
|
+
await db.sequelize.query('DROP FUNCTION IF EXISTS pg_temp.testfunc()');
|
1671
|
+
|
1662
1672
|
console.log("");
|
1663
1673
|
console.log("########################################################")
|
1664
1674
|
console.log(" Schedules Migration ")
|
@@ -1670,7 +1680,8 @@ const server = {
|
|
1670
1680
|
let maxId = maxIds|| 0;
|
1671
1681
|
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."Schedules__id_seq"`);
|
1672
1682
|
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Schedules__id_seq" RESTART WITH ${maxId + 1}`);
|
1673
|
-
|
1683
|
+
await db.sequelize.query(`DROP FUNCTION IF EXISTS ${db_schema}."pg_temp.testfunc()"`);
|
1684
|
+
|
1674
1685
|
const scheduleApi = await api.Schedule()
|
1675
1686
|
const userMail = await Users.findOne({ where: { email: 'ccci_integrator@gmail.com' } });
|
1676
1687
|
|
@@ -1793,9 +1804,9 @@ const server = {
|
|
1793
1804
|
console.log("########################################################")
|
1794
1805
|
console.log("")
|
1795
1806
|
logger.info('Schedule Data Migration Completed');
|
1796
|
-
logger.info(`Total
|
1797
|
-
logger.info(`Total Schedule
|
1798
|
-
logger.info(`Total
|
1807
|
+
logger.info(`Total Successful Schedule Records Created: ${createdCounter}/${createdCounter}`);
|
1808
|
+
logger.info(`Total Existing Schedule Records: ${errorCounter}/${errorCounter}`);
|
1809
|
+
logger.info(`Total Records: ${createdCounter + errorCounter}`);
|
1799
1810
|
console.log("")
|
1800
1811
|
console.log("########################################################")
|
1801
1812
|
console.log("")
|
@@ -2042,9 +2053,9 @@ const server = {
|
|
2042
2053
|
console.log("########################################################")
|
2043
2054
|
console.log("")
|
2044
2055
|
logger.info('Student Data Migration Completed');
|
2045
|
-
logger.info(`Total
|
2046
|
-
logger.info(`Total Student
|
2047
|
-
logger.info(`Total
|
2056
|
+
logger.info(`Total Successful Student Records Created: ${createdCounter}/${createdCounter}`);
|
2057
|
+
logger.info(`Total Existing Student Records: ${errorCounter}/${errorCounter}`);
|
2058
|
+
logger.info(`Total Records: ${createdCounter + errorCounter}`);
|
2048
2059
|
console.log("")
|
2049
2060
|
console.log("########################################################")
|
2050
2061
|
console.log("")
|
@@ -2062,166 +2073,166 @@ const server = {
|
|
2062
2073
|
}
|
2063
2074
|
},
|
2064
2075
|
|
2065
|
-
async Studentsss(){
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2076
|
+
// async Studentsss(){
|
2077
|
+
// try {
|
2078
|
+
// console.log("");
|
2079
|
+
// console.log("########################################################")
|
2080
|
+
// console.log(" Students Migration ")
|
2081
|
+
// console.log("########################################################")
|
2082
|
+
// console.log("");
|
2083
|
+
|
2084
|
+
// const db_schema = schema
|
2085
|
+
// let maxIds = await Students.max('_id'); // Fetch maximum _id directly from the Students model
|
2086
|
+
// let maxId = maxIds|| 0;
|
2087
|
+
// await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."Students__id_seq"`);
|
2088
|
+
// await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Students__id_seq" RESTART WITH ${maxId + 1}`);
|
2089
|
+
|
2090
|
+
// const studentApi = await api.Student()
|
2091
|
+
|
2092
|
+
// const campusSeq = await Campuses.findAll()
|
2093
|
+
// const courseSeq = await Courses.findAll()
|
2094
|
+
// const collegeSeq = await Colleges.findAll()
|
2095
|
+
// const semesterSeq = await Semesters.findAll()
|
2096
|
+
// const acadYearSeq = await AcademicYears.findAll()
|
2097
|
+
// const userSeq = await Users.findAll()
|
2098
|
+
|
2099
|
+
// const userMail = await Users.findOne({ where: { email: 'ccci_integrator@gmail.com' } });
|
2100
|
+
// const campusDefault = await Campuses.findOne({ where: { name: 'Campus Default' } });
|
2101
|
+
// const courseDefault = await Courses.findOne({ where: { name: 'Course Default' } });
|
2102
|
+
// const collegeDefault = await Colleges.findOne({ where: { name: 'Colleges Default' } });
|
2103
|
+
|
2104
|
+
// let createdCounter = 0
|
2105
|
+
// let errorCounter = 0
|
2106
|
+
// let uniqueErrors = new Set()
|
2107
|
+
|
2108
|
+
// let uNum = new Set()
|
2109
|
+
// let uLname = new Set()
|
2110
|
+
// let uMname = new Set()
|
2111
|
+
// let uFname = new Set()
|
2112
|
+
// let uCourse = new Set()
|
2113
|
+
// let uCampus = new Set()
|
2114
|
+
|
2115
|
+
// let newStudent = []
|
2116
|
+
|
2117
|
+
// const exStudent = await Students.findAll()
|
2118
|
+
// const exStudentMap = new Map(exStudent.map(student => [`[${student.studentNumber}] - ${student.lastName}, ${student.firstName} ${student.middleName} [${student.courseId}, ${student.campusId}]`, student]))
|
2108
2119
|
|
2109
|
-
|
2120
|
+
// const {data} = studentApi
|
2110
2121
|
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2122
|
+
// for (let i = 0; i < data.length; i++){
|
2123
|
+
// try {
|
2124
|
+
// let _student = data[i]
|
2114
2125
|
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2126
|
+
// let _campus = campusSeq.find(a => a.name === _student?.campus)
|
2127
|
+
// let _course = courseSeq.find(b => b.name === _student?.course)
|
2128
|
+
// let _college = collegeSeq.find(c => c.name === _student?.college)
|
2118
2129
|
|
2119
|
-
|
2130
|
+
// let findUser = await userSeq.find( f => f.lastName === _student?.last_name && f.firstName === _student?.first_name && f.middleName === _student?.middle_name)
|
2120
2131
|
|
2121
|
-
|
2122
|
-
|
2132
|
+
// let modifiedById = userMail?._id
|
2133
|
+
// let createdById = userMail?._id
|
2123
2134
|
|
2124
|
-
|
2135
|
+
// let fromPrompts = await Picked()
|
2125
2136
|
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2150
|
-
|
2151
|
-
|
2152
|
-
|
2153
|
-
|
2154
|
-
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2137
|
+
// // let semester = "2nd Semester"
|
2138
|
+
// let semester = fromPrompts.semester
|
2139
|
+
// let yearsFrom = fromPrompts.yearFrom
|
2140
|
+
// let yearsTo = fromPrompts.yearTo
|
2141
|
+
|
2142
|
+
// let _semester = semesterSeq.find(sem => sem.code === semester)
|
2143
|
+
// let _acadYear = acadYearSeq.find(yr => yr.from === parseInt(yearsFrom) && yr.to === parseInt(yearsTo))
|
2144
|
+
|
2145
|
+
// let studentNumber = _student?.student_number
|
2146
|
+
// let firstName = _student?.first_name
|
2147
|
+
// let lastName = _student?.last_name
|
2148
|
+
// let middleName = _student?.middle_name
|
2149
|
+
// let courseId = _course?._id??courseDefault?._id
|
2150
|
+
// let campusId = _campus?._id??campusDefault?._id
|
2151
|
+
|
2152
|
+
// let getUserName = Mixins.generateUsername(firstName, lastName)
|
2153
|
+
// let email = `${getUserName}@msumarinduque.edu.ph`
|
2154
|
+
|
2155
|
+
// let userId = findUser?._id
|
2156
|
+
|
2157
|
+
|
2158
|
+
// if(uNum.has(studentNumber) && uLname.has(lastName) && uFname.has(firstName) && uMname.has(middleName) && uCourse.has(courseId) && uCampus.has(campusId)){
|
2159
|
+
// const errorMsg = `Duplicate Payload Found: [${studentNumber}] - ${lastName}, ${firstName} ${middleName} [courseId: ${courseId}, campusId:${campusId}]`
|
2160
|
+
// if(!uniqueErrors.has(errorMsg)){
|
2161
|
+
// logger.error(`${errorCounter + 1}/${errorCounter + 1}: ${errorMsg}`)
|
2162
|
+
// uniqueErrors.add(errorMsg)
|
2163
|
+
// errorCounter++
|
2164
|
+
// }
|
2165
|
+
// }
|
2166
|
+
// else if ( exStudentMap.has(`[${studentNumber}] - ${lastName}, ${firstName} ${middleName} [${courseId}, ${campusId}]`)){
|
2167
|
+
// const exStudent = exStudentMap.get(`[${studentNumber}] - ${lastName}, ${firstName} ${middleName} [${courseId}, ${campusId}]`)
|
2168
|
+
// const errorMsg = `Existing Data Found:[${exStudent.studentNumber}] - ${exStudent.lastName}, ${exStudent.firstName} ${exStudent.middleName} [courseId: ${exStudent.courseId}, campusId: ${exStudent.campusId}]`
|
2169
|
+
// if(!uniqueErrors.has(errorMsg)){
|
2170
|
+
// logger.error(`${errorCounter + 1}/${errorCounter + 1}: ${errorMsg}`)
|
2171
|
+
// uniqueErrors.add(errorMsg)
|
2172
|
+
// errorCounter++
|
2173
|
+
// }
|
2174
|
+
// }
|
2175
|
+
// else{
|
2176
|
+
// uNum.add(studentNumber)
|
2177
|
+
// uLname.add(lastName)
|
2178
|
+
// uMname.add(middleName)
|
2179
|
+
// uFname.add(firstName)
|
2180
|
+
// uCourse.add(courseId)
|
2181
|
+
// uCampus.add(campusId)
|
2182
|
+
// newStudent.push({
|
2183
|
+
// studentNumber: _student?.student_number,
|
2184
|
+
// firstName: _student?.first_name,
|
2185
|
+
// lastName: _student?.last_name,
|
2186
|
+
// middleName: _student?.middle_name,
|
2187
|
+
// email: email,
|
2188
|
+
// courseId: _course?._id??courseDefault?._id,
|
2189
|
+
// campusId: _campus?._id??campusDefault?._id,
|
2190
|
+
// collegeId: _college?._id??collegeDefault?._id,
|
2191
|
+
// admittedYearId: _acadYear?._id ?? null,
|
2192
|
+
// admittedSemId: _semester?._id ?? null,
|
2193
|
+
// modifiedById,
|
2194
|
+
// createdById,
|
2195
|
+
// userId
|
2196
|
+
// })
|
2197
|
+
// }
|
2187
2198
|
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2199
|
+
// } catch (error) {
|
2200
|
+
// logger.error(`Error occurred: ${error.stack} ${error}`);
|
2201
|
+
// }
|
2202
|
+
// }
|
2203
|
+
|
2204
|
+
// if (newStudent.length > 0) {
|
2205
|
+
// await Students.bulkCreate(newStudent)
|
2206
|
+
// createdCounter += newStudent.length
|
2196
2207
|
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2208
|
+
// newStudent.forEach((exStudent, index) => {
|
2209
|
+
// logger.info(`${index + 1}/${index + 1}: New Student Record Created: [${exStudent.studentNumber}] - ${exStudent.lastName}, ${exStudent.firstName} ${exStudent.middleName} [courseId: ${exStudent.courseId}, campusId: ${exStudent.campusId}]`)
|
2210
|
+
// });
|
2211
|
+
// }
|
2212
|
+
|
2213
|
+
// console.log("");
|
2214
|
+
// console.log("########################################################")
|
2215
|
+
// console.log("")
|
2216
|
+
// logger.info('Student Data Migration Completed');
|
2217
|
+
// logger.info(`Total Successful Student Records Created: ${createdCounter}/${createdCounter}`);
|
2218
|
+
// logger.info(`Total Existing Student Records: ${errorCounter}/${errorCounter}`);
|
2219
|
+
// logger.info(`Total Records: ${createdCounter + errorCounter}`);
|
2220
|
+
// console.log("")
|
2221
|
+
// console.log("########################################################")
|
2222
|
+
// console.log("")
|
2223
|
+
|
2224
|
+
// let totalSummary = {
|
2225
|
+
// itemLength: createdCounter + errorCounter,
|
2226
|
+
// error: errorCounter,
|
2227
|
+
// success: createdCounter
|
2228
|
+
// }
|
2229
|
+
// return totalSummary
|
2230
|
+
|
2231
|
+
// } catch (error) {
|
2232
|
+
// logger.error(`Error occurred: ${error.stack} ${error}`);
|
2222
2233
|
|
2223
|
-
|
2224
|
-
},
|
2234
|
+
// }
|
2235
|
+
// },
|
2225
2236
|
|
2226
2237
|
async Section() {
|
2227
2238
|
try {
|
@@ -2419,9 +2430,9 @@ const server = {
|
|
2419
2430
|
console.log("########################################################");
|
2420
2431
|
console.log("");
|
2421
2432
|
logger.info('Section Data Migration Completed');
|
2422
|
-
logger.info(`Total
|
2423
|
-
logger.info(`Total Section
|
2424
|
-
logger.info(`Total
|
2433
|
+
logger.info(`Total Successful Section Records Created: ${createdCounter}/${createdCounter}`);
|
2434
|
+
logger.info(`Total Existing Section Records: ${errorCounter}/${errorCounter}`);
|
2435
|
+
logger.info(`Total Records: ${createdCounter + errorCounter}`);
|
2425
2436
|
console.log("");
|
2426
2437
|
console.log("########################################################");
|
2427
2438
|
console.log("");
|
@@ -2439,246 +2450,12 @@ const server = {
|
|
2439
2450
|
}
|
2440
2451
|
},
|
2441
2452
|
|
2442
|
-
async EnrolledStudentss(){
|
2443
|
-
try {
|
2444
|
-
console.log("");
|
2445
|
-
console.log("########################################################")
|
2446
|
-
console.log(" Enrolled Students Migration ")
|
2447
|
-
console.log("########################################################")
|
2448
|
-
console.log("");
|
2449
|
-
|
2450
|
-
const db_schema = schema
|
2451
|
-
let maxIds = await EnrolledStudents.max('_id'); // Fetch maximum _id directly from the EnrolledStudents model
|
2452
|
-
let maxId = maxIds|| 0;
|
2453
|
-
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."EnrolledStudents__id_seq"`);
|
2454
|
-
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."EnrolledStudents__id_seq" RESTART WITH ${maxId + 1}`);
|
2455
|
-
|
2456
|
-
const studentApi = (await api.Student()).data
|
2457
|
-
const instructorApi = await api.Instructor()
|
2458
|
-
|
2459
|
-
const studentSeq = await Students.findAll()
|
2460
|
-
const courseSeq = await Courses.findAll()
|
2461
|
-
const campusSeq = await Campuses.findAll()
|
2462
|
-
const acadYearSeq = await AcademicYears.findAll()
|
2463
|
-
const semesterSeq = await Semesters.findAll()
|
2464
|
-
const sectionSeq = await Sections.findAll()
|
2465
|
-
const instructorSeq = await Instructors.findAll()
|
2466
|
-
const subjectSeq = await Subjects.findAll()
|
2467
|
-
|
2468
|
-
const userMail = await Users.findOne({ where: { email: 'ccci_integrator@gmail.com' } });
|
2469
|
-
|
2470
|
-
let createdCounter = 0
|
2471
|
-
let errorCounter = 0
|
2472
|
-
let uniqueErrors = new Set()
|
2473
|
-
|
2474
|
-
let uStud = new Set()
|
2475
|
-
let uCrs = new Set()
|
2476
|
-
let uIns = new Set()
|
2477
|
-
let uSec = new Set()
|
2478
|
-
let uCam = new Set()
|
2479
|
-
let uYear = new Set()
|
2480
|
-
let uSem = new Set()
|
2481
|
-
let uGrade = new Set()
|
2482
|
-
let uRemarks = new Set()
|
2483
|
-
let uAllStat = new Set()
|
2484
|
-
|
2485
|
-
let newEnroll = []
|
2486
|
-
|
2487
|
-
const existings = await EnrolledStudents.findAll()
|
2488
|
-
const existingEnrolledMap = new Map(existings.map(enroll => [`[${enroll.studentId} ${enroll.instructorId} ${enroll.sectionId}] ${enroll.finalGrade} ${enroll.remarks} ${enroll.overAllStatus}`, enroll]))
|
2489
|
-
|
2490
|
-
for (let i = 0; i < studentApi.length; i++){
|
2491
|
-
try {
|
2492
|
-
let _student = studentApi[i]
|
2493
|
-
let student = studentSeq.find(st => st.studentNumber === _student?.student_number)
|
2494
|
-
let campus = campusSeq.find(ca => ca.name === _student?.campus)
|
2495
|
-
let course = courseSeq.find(cr => cr.name === _student?.course)
|
2496
|
-
let _students = studentApi[i].subjects_enrolled
|
2497
|
-
|
2498
|
-
let fromPrompts = await Picked()
|
2499
|
-
|
2500
|
-
let semester = fromPrompts.semester
|
2501
|
-
let yearsFrom = fromPrompts.yearFrom
|
2502
|
-
let yearsTo = fromPrompts.yearTo
|
2503
|
-
let _semester = semesterSeq.find(sem => sem.code === semester)
|
2504
|
-
let _acadYear = acadYearSeq.find(yr => yr.from === parseInt(yearsFrom) && yr.to === parseInt(yearsTo))
|
2505
|
-
|
2506
|
-
let modifiedById = userMail?._id;
|
2507
|
-
let createdById = userMail?._id;
|
2508
|
-
|
2509
|
-
let migratedAt = new Date() //present date of the migration
|
2510
|
-
let migratedTable = 'campuses' // sql counterpart main table
|
2511
|
-
let referenceId = _campus?.id // id of the data
|
2512
|
-
let isMigrated = true
|
2513
|
-
|
2514
|
-
for (let j = 0; j < _students.length; j++){
|
2515
|
-
let instrcutor = _students[j].faculty_id
|
2516
|
-
let sections = _students[j].section_name
|
2517
|
-
let fGrade = _students[j].final_grade
|
2518
|
-
let rmarks = _students[j].remarks
|
2519
|
-
|
2520
|
-
let _inst = instructorApi.find(i => i.faculty_id === instrcutor)
|
2521
|
-
let _instructor = instructorSeq.find(ins => ins.employeeNumber === _inst?.faculty_id)
|
2522
|
-
let _section = sectionSeq.find(sec => sec.name === sections)
|
2523
|
-
|
2524
|
-
|
2525
|
-
if (!_inst) {
|
2526
|
-
continue;
|
2527
|
-
}
|
2528
|
-
|
2529
|
-
if (!_student) {
|
2530
|
-
continue;
|
2531
|
-
}
|
2532
|
-
|
2533
|
-
if (!student) {
|
2534
|
-
continue;
|
2535
|
-
}
|
2536
|
-
|
2537
|
-
let overAllStatus = null
|
2538
|
-
let finalG = fGrade
|
2539
|
-
|
2540
|
-
let graded = false
|
2541
|
-
if (finalG){
|
2542
|
-
graded = true
|
2543
|
-
}
|
2544
|
-
else if (!finalG){
|
2545
|
-
finalG = 0
|
2546
|
-
}
|
2547
|
-
|
2548
|
-
let remarks = rmarks?.toUpperCase()??null
|
2549
|
-
if (remarks === 'INCOMPLETE'){
|
2550
|
-
finalG = 0
|
2551
|
-
overAllStatus = "INC"
|
2552
|
-
}
|
2553
|
-
else if (remarks === 'UNOFFICIALLY DROPPED'){
|
2554
|
-
finalG = 0
|
2555
|
-
overAllStatus = "UD"
|
2556
|
-
}
|
2557
|
-
else if (remarks === 'UNAUTHORIZED WITHDRAWAL'){
|
2558
|
-
finalG = 0
|
2559
|
-
overAllStatus = "UW"
|
2560
|
-
}
|
2561
|
-
else if (remarks === 'DROPPED'){
|
2562
|
-
finalG = 0
|
2563
|
-
overAllStatus = "DRP"
|
2564
|
-
}
|
2565
|
-
else if (remarks === 'NO CREDIT'){
|
2566
|
-
finalG = 0
|
2567
|
-
overAllStatus = "IN-PROG"
|
2568
|
-
}
|
2569
|
-
else if (remarks === 'CREDITED'){
|
2570
|
-
finalG = 0
|
2571
|
-
overAllStatus = "UD"
|
2572
|
-
}
|
2573
|
-
else if (remarks === 'PASSED'){
|
2574
|
-
overAllStatus = "PASSED"
|
2575
|
-
}
|
2576
|
-
else if (!remarks){
|
2577
|
-
finalG = 0
|
2578
|
-
}
|
2579
|
-
if(finalG === 5.00){
|
2580
|
-
remarks = "FAILED"
|
2581
|
-
overAllStatus = "FAILED"
|
2582
|
-
}
|
2583
|
-
|
2584
|
-
|
2585
|
-
let studentId = student?._id
|
2586
|
-
let courseId = course?._id
|
2587
|
-
let instructorId = _instructor?._id??null
|
2588
|
-
let sectionId = _section?._id??null
|
2589
|
-
let campusId = campus?._id
|
2590
|
-
let academicYearId = _acadYear?._id
|
2591
|
-
let semesterId = _semester?._id
|
2592
|
-
let finalGrade = finalG
|
2593
|
-
|
2594
|
-
if(uStud.has(studentId) && uIns.has(instructorId) && uSec.has(sectionId) && uGrade.has(finalGrade) && uRemarks.has(remarks) && uAllStat.has(overAllStatus)){
|
2595
|
-
const errorMsg = `Duplicate Payload Found: [${studentId}] - [${courseId}, ${instructorId}, ${sectionId}] = ${finalGrade}, ${remarks}, ${overAllStatus}`
|
2596
|
-
if(!uniqueErrors.has(errorMsg)){
|
2597
|
-
logger.error(`${errorCounter + 1}/${errorCounter + 1}: ${errorMsg}`)
|
2598
|
-
uniqueErrors.add(errorMsg)
|
2599
|
-
errorCounter++
|
2600
|
-
}
|
2601
|
-
}
|
2602
|
-
else if (existingEnrolledMap.has(`[${studentId} ${instructorId} ${sectionId} ${finalGrade}] ${remarks} ${overAllStatus}`)){
|
2603
|
-
const existings = existingEnrolledMap.get(`[${studentId} ${instructorId} ${sectionId} ${finalGrade}] ${remarks} ${overAllStatus}`)
|
2604
|
-
const errorMsg = `Existing Data Found: [${existings.studentId}] - [${existings.courseId}, ${existings.instructorId}, ${existings.sectionId}] = ${existings.finalGrade}, ${existings.remarks}, ${existings.overAllStatus}`
|
2605
|
-
if(!uniqueErrors.has(errorMsg)){
|
2606
|
-
logger.error(`${errorCounter + 1}/${errorCounter + 1}: ${errorMsg}`)
|
2607
|
-
uniqueErrors.add(errorMsg)
|
2608
|
-
errorCounter++
|
2609
|
-
}
|
2610
|
-
}
|
2611
|
-
else{
|
2612
|
-
uStud.add(studentId)
|
2613
|
-
uCrs.add(courseId)
|
2614
|
-
uIns.add(instructorId)
|
2615
|
-
uSec.add(sectionId)
|
2616
|
-
uCam.add(campusId)
|
2617
|
-
uYear.add(academicYearId)
|
2618
|
-
uSem.add(semesterId)
|
2619
|
-
uGrade.add(finalGrade)
|
2620
|
-
uAllStat.add(overAllStatus)
|
2621
|
-
uRemarks.add(remarks)
|
2622
|
-
newEnroll.push({
|
2623
|
-
studentId: student?._id,
|
2624
|
-
courseId: course?._id,
|
2625
|
-
instructorId: _instructor?._id??null,
|
2626
|
-
sectionId: _section?._id??null,
|
2627
|
-
campusId: campus?._id,
|
2628
|
-
academicYearId: _acadYear?._id,
|
2629
|
-
semesterId: _semester?._id,
|
2630
|
-
finalGrade: finalG,
|
2631
|
-
graded,
|
2632
|
-
overAllStatus,
|
2633
|
-
remarks,
|
2634
|
-
createdById,
|
2635
|
-
modifiedById,
|
2636
|
-
})
|
2637
|
-
}
|
2638
|
-
}
|
2639
|
-
} catch (error) {
|
2640
|
-
logger.error(`Error occurred: ${error.stack} ${error}`);
|
2641
|
-
}
|
2642
|
-
}
|
2643
|
-
|
2644
|
-
if (newEnroll.length > 0) {
|
2645
|
-
await EnrolledStudents.bulkCreate(newEnroll)
|
2646
|
-
createdCounter += newEnroll.length
|
2647
|
-
|
2648
|
-
newEnroll.forEach((es, index) => {
|
2649
|
-
logger.info(`${index + 1}/${index + 1}: New Enrolled Students Record Created: [${es.studentId}] - [${es.courseId}, ${es.instructorId}, ${es.sectionId}] = ${es.finalGrade}, ${es.remarks}, ${es.overAllStatus}`)
|
2650
|
-
});
|
2651
|
-
}
|
2652
|
-
|
2653
|
-
console.log("");
|
2654
|
-
console.log("########################################################")
|
2655
|
-
console.log("")
|
2656
|
-
logger.info('Enrolled Student Data Migration Completed');
|
2657
|
-
logger.info(`Total successful Enrolled Student records created: ${createdCounter}/${createdCounter}`);
|
2658
|
-
logger.info(`Total Enrolled Student Error Records: ${errorCounter}/${errorCounter}`);
|
2659
|
-
logger.info(`Total records: ${createdCounter + errorCounter}`);
|
2660
|
-
console.log("")
|
2661
|
-
console.log("########################################################")
|
2662
|
-
console.log("")
|
2663
|
-
|
2664
|
-
let totalSummary = {
|
2665
|
-
itemLength: createdCounter + errorCounter,
|
2666
|
-
error: errorCounter,
|
2667
|
-
success: createdCounter
|
2668
|
-
}
|
2669
|
-
return totalSummary
|
2670
|
-
|
2671
|
-
} catch (error) {
|
2672
|
-
logger.error(`Error occurred: ${error.stack} ${error}`);
|
2673
|
-
|
2674
|
-
}
|
2675
|
-
},
|
2676
2453
|
|
2677
2454
|
async EnrolledStudent(){
|
2678
2455
|
try {
|
2679
2456
|
console.log("");
|
2680
2457
|
console.log("########################################################")
|
2681
|
-
console.log("
|
2458
|
+
console.log(" Enrolled Students Migration ")
|
2682
2459
|
console.log("########################################################")
|
2683
2460
|
console.log("");
|
2684
2461
|
|
@@ -2862,8 +2639,8 @@ const server = {
|
|
2862
2639
|
console.log("########################################################")
|
2863
2640
|
console.log("")
|
2864
2641
|
logger.info(' Enrolled Student Data Migration Completed');
|
2865
|
-
logger.info(`Total
|
2866
|
-
logger.info(`Total Enrolled Student
|
2642
|
+
logger.info(`Total Successful Enrolled Student Records Created: ${createdCounter}/${createdCounter}`);
|
2643
|
+
logger.info(`Total Existing Enrolled Student Records: ${errorCounter}/${errorCounter}`);
|
2867
2644
|
console.log("")
|
2868
2645
|
console.log("########################################################")
|
2869
2646
|
console.log("")
|
@@ -2904,7 +2681,7 @@ async function runServerFunctions() {
|
|
2904
2681
|
console.log("");
|
2905
2682
|
console.log(`${key.toUpperCase()}:`);
|
2906
2683
|
logger.info(`total Success ${key} Record: ${value?.success??""}/${value?.itemLength??""}`);
|
2907
|
-
logger.info(`total
|
2684
|
+
logger.info(`total Existing ${key} Record: ${value?.error??""}/${value?.itemLength??""}`);
|
2908
2685
|
console.log("");
|
2909
2686
|
});
|
2910
2687
|
|
@@ -2925,12 +2702,10 @@ module.exports = {
|
|
2925
2702
|
AcademicDepartments: server.AcademicDepartment,
|
2926
2703
|
Course: server.Course,
|
2927
2704
|
Room: server.Room,
|
2928
|
-
UserInstructor: server.UserInstructor,
|
2929
2705
|
Instructor: server.Instructor,
|
2930
2706
|
AcademicYear: server.AcademicYear,
|
2931
2707
|
Subject: server.Subject,
|
2932
2708
|
Schedule: server.Schedule,
|
2933
|
-
UserStudents: server.UserStudents,
|
2934
2709
|
Student: server.Student,
|
2935
2710
|
Section: server.Section,
|
2936
2711
|
EnrolledStudent: server.EnrolledStudent,
|