lms-sync 1.0.12 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- package/apiConnections/mapping.js +86 -49
- package/models/index.js +1 -1
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
const db = require('../models')
|
1
|
+
const {db, schema} = require('../models')
|
2
2
|
const logger = require('../utils/logger')
|
3
3
|
const api = require('../apiConnections/apiConnects')
|
4
4
|
const moment = require('moment')
|
@@ -39,9 +39,10 @@ const server = {
|
|
39
39
|
let errorCounter = 0
|
40
40
|
let uniqueErrors = new Set()
|
41
41
|
|
42
|
-
|
42
|
+
const db_schema = schema
|
43
|
+
// let maxIds = await Campuses.max('_id'); = await Campuses.max('_id'); // Fetch maximum _id directly from the campuses model
|
43
44
|
// let maxId = maxIds|| 0;
|
44
|
-
// await db.sequelize.query(`ALTER SEQUENCE
|
45
|
+
// await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Campuses__id_seq" RESTART WITH ${maxId + 1}`);
|
45
46
|
|
46
47
|
for (let i = 0; i < campusApi.length; i++){
|
47
48
|
try {
|
@@ -78,7 +79,8 @@ const server = {
|
|
78
79
|
}
|
79
80
|
|
80
81
|
} catch (error) {
|
81
|
-
|
82
|
+
logger.error(`Error occurred: ${error}`);
|
83
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
82
84
|
}
|
83
85
|
}
|
84
86
|
|
@@ -100,7 +102,8 @@ const server = {
|
|
100
102
|
return totalSummary
|
101
103
|
|
102
104
|
} catch (error) {
|
103
|
-
|
105
|
+
logger.error(`Error occurred: ${error}`);
|
106
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
104
107
|
|
105
108
|
}
|
106
109
|
},
|
@@ -123,9 +126,10 @@ const server = {
|
|
123
126
|
let errorCounter = 0
|
124
127
|
let uniqueErrors = new Set()
|
125
128
|
|
126
|
-
|
129
|
+
const db_schema = schema
|
130
|
+
// let maxIds = await Campuses.max('_id'); = await Colleges.max('_id'); // Fetch maximum _id directly from the Colleges model
|
127
131
|
// let maxId = maxIds|| 0;
|
128
|
-
// await db.sequelize.query(`ALTER SEQUENCE
|
132
|
+
// await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Colleges__id_seq" RESTART WITH ${maxId + 1}`);
|
129
133
|
|
130
134
|
for (let i = 0; i < collegeApi.length; i++){
|
131
135
|
try {
|
@@ -167,7 +171,8 @@ const server = {
|
|
167
171
|
}
|
168
172
|
|
169
173
|
} catch (error) {
|
170
|
-
|
174
|
+
logger.error(`Error occurred: ${error}`);
|
175
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
171
176
|
}
|
172
177
|
}
|
173
178
|
|
@@ -189,7 +194,8 @@ const server = {
|
|
189
194
|
return totalSummary
|
190
195
|
|
191
196
|
} catch (error) {
|
192
|
-
|
197
|
+
logger.error(`Error occurred: ${error}`);
|
198
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
193
199
|
|
194
200
|
}
|
195
201
|
},
|
@@ -215,9 +221,10 @@ const server = {
|
|
215
221
|
let errorCounter = 0
|
216
222
|
let uniqueErrors = new Set()
|
217
223
|
|
218
|
-
|
224
|
+
const db_schema = schema
|
225
|
+
// let maxIds = await Campuses.max('_id'); = await AcademicDepartments.max('_id'); // Fetch maximum _id directly from the AcademicDepartments model
|
219
226
|
// let maxId = maxIds|| 0;
|
220
|
-
// await db.sequelize.query(`ALTER SEQUENCE
|
227
|
+
// await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."AcademicDepartments__id_seq" RESTART WITH ${maxId + 1}`);
|
221
228
|
for (let i = 0; i < departmentApi.length; i++){
|
222
229
|
try {
|
223
230
|
let _acadDept = departmentApi[i]
|
@@ -269,7 +276,8 @@ const server = {
|
|
269
276
|
}
|
270
277
|
|
271
278
|
} catch (error) {
|
272
|
-
|
279
|
+
logger.error(`Error occurred: ${error}`);
|
280
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
273
281
|
}
|
274
282
|
}
|
275
283
|
|
@@ -291,7 +299,8 @@ const server = {
|
|
291
299
|
return totalSummary
|
292
300
|
|
293
301
|
} catch (error) {
|
294
|
-
|
302
|
+
logger.error(`Error occurred: ${error}`);
|
303
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
295
304
|
|
296
305
|
}
|
297
306
|
},
|
@@ -319,9 +328,10 @@ const server = {
|
|
319
328
|
let errorCounter = 0
|
320
329
|
let uniqueErrors = new Set()
|
321
330
|
|
322
|
-
|
331
|
+
const db_schema = schema
|
332
|
+
// let maxIds = await Campuses.max('_id'); = await Courses.max('_id'); // Fetch maximum _id directly from the Courses model
|
323
333
|
// let maxId = maxIds|| 0;
|
324
|
-
// await db.sequelize.query(`ALTER SEQUENCE
|
334
|
+
// await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Courses__id_seq" RESTART WITH ${maxId + 1}`);
|
325
335
|
|
326
336
|
for (let i = 0; i < studentApi.length; i++){
|
327
337
|
try {
|
@@ -374,7 +384,8 @@ const server = {
|
|
374
384
|
}
|
375
385
|
|
376
386
|
} catch (error) {
|
377
|
-
|
387
|
+
logger.error(`Error occurred: ${error}`);
|
388
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
378
389
|
}
|
379
390
|
}
|
380
391
|
|
@@ -400,7 +411,8 @@ const server = {
|
|
400
411
|
return totalSummary
|
401
412
|
|
402
413
|
} catch (error) {
|
403
|
-
|
414
|
+
logger.error(`Error occurred: ${error}`);
|
415
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
404
416
|
}
|
405
417
|
},
|
406
418
|
|
@@ -426,9 +438,10 @@ const server = {
|
|
426
438
|
let uniqueErrors = new Set()
|
427
439
|
|
428
440
|
|
429
|
-
|
441
|
+
const db_schema = schema
|
442
|
+
// let maxIds = await Campuses.max('_id'); = await Rooms.max('_id'); // Fetch maximum _id directly from the Rooms model
|
430
443
|
// let maxId = maxIds|| 0;
|
431
|
-
// await db.sequelize.query(`ALTER SEQUENCE
|
444
|
+
// await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Rooms__id_seq" RESTART WITH ${maxId + 1}`);
|
432
445
|
|
433
446
|
|
434
447
|
for (let i = 0; i < roomApi.length; i++){
|
@@ -489,7 +502,8 @@ const server = {
|
|
489
502
|
}
|
490
503
|
|
491
504
|
} catch (error) {
|
492
|
-
|
505
|
+
logger.error(`Error occurred: ${error}`);
|
506
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
493
507
|
}
|
494
508
|
}
|
495
509
|
|
@@ -511,7 +525,8 @@ const server = {
|
|
511
525
|
return totalSummary
|
512
526
|
|
513
527
|
} catch (error) {
|
514
|
-
|
528
|
+
logger.error(`Error occurred: ${error}`);
|
529
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
515
530
|
|
516
531
|
}
|
517
532
|
},
|
@@ -536,9 +551,10 @@ const server = {
|
|
536
551
|
let uniqueErrors = new Set()
|
537
552
|
|
538
553
|
|
539
|
-
|
554
|
+
const db_schema = schema
|
555
|
+
// let maxIds = await Campuses.max('_id'); = await Instructors.max('_id'); // Fetch maximum _id directly from the Instructors model
|
540
556
|
// let maxId = maxIds|| 0;
|
541
|
-
// await db.sequelize.query(`ALTER SEQUENCE
|
557
|
+
// await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Instructors__id_seq" RESTART WITH ${maxId + 1}`);
|
542
558
|
|
543
559
|
|
544
560
|
for (let i = 0; i < instructorApi.length; i++){
|
@@ -594,7 +610,8 @@ const server = {
|
|
594
610
|
}
|
595
611
|
|
596
612
|
} catch (error) {
|
597
|
-
|
613
|
+
logger.error(`Error occurred: ${error}`);
|
614
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
598
615
|
}
|
599
616
|
}
|
600
617
|
|
@@ -616,7 +633,8 @@ const server = {
|
|
616
633
|
return totalSummary
|
617
634
|
|
618
635
|
} catch (error) {
|
619
|
-
|
636
|
+
logger.error(`Error occurred: ${error}`);
|
637
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
620
638
|
|
621
639
|
}
|
622
640
|
},
|
@@ -639,9 +657,10 @@ const server = {
|
|
639
657
|
const { acadYearResult, currentSchoolYear } = acadYearApi;
|
640
658
|
|
641
659
|
|
642
|
-
|
660
|
+
const db_schema = schema
|
661
|
+
// let maxIds = await Campuses.max('_id'); = await AcademicYears.max('_id'); // Fetch maximum _id directly from the AcademicYears model
|
643
662
|
// let maxId = maxIds|| 0;
|
644
|
-
// await db.sequelize.query(`ALTER SEQUENCE
|
663
|
+
// await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."AcademicYears__id_seq" RESTART WITH ${maxId + 1}`);
|
645
664
|
|
646
665
|
|
647
666
|
for (let i = 0; i < acadYearResult.length; i++){
|
@@ -689,7 +708,8 @@ const server = {
|
|
689
708
|
}
|
690
709
|
|
691
710
|
} catch (error) {
|
692
|
-
|
711
|
+
logger.error(`Error occurred: ${error}`);
|
712
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
693
713
|
}
|
694
714
|
}
|
695
715
|
|
@@ -711,7 +731,8 @@ const server = {
|
|
711
731
|
return totalSummary
|
712
732
|
|
713
733
|
} catch (error) {
|
714
|
-
|
734
|
+
logger.error(`Error occurred: ${error}`);
|
735
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
715
736
|
|
716
737
|
}
|
717
738
|
},
|
@@ -736,9 +757,10 @@ const server = {
|
|
736
757
|
let uniqueErrors = new Set()
|
737
758
|
|
738
759
|
|
739
|
-
|
760
|
+
const db_schema = schema
|
761
|
+
// let maxIds = await Campuses.max('_id'); = await Subjects.max('_id'); // Fetch maximum _id directly from the Subjects model
|
740
762
|
// let maxId = maxIds|| 0;
|
741
|
-
// await db.sequelize.query(`ALTER SEQUENCE
|
763
|
+
// await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Subjects__id_seq" RESTART WITH ${maxId + 1}`);
|
742
764
|
|
743
765
|
|
744
766
|
for (let i = 0; i < studentSubject.length; i++){
|
@@ -805,7 +827,8 @@ const server = {
|
|
805
827
|
|
806
828
|
|
807
829
|
} catch (error) {
|
808
|
-
|
830
|
+
logger.error(`Error occurred: ${error}`);
|
831
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
809
832
|
}
|
810
833
|
}
|
811
834
|
|
@@ -827,7 +850,8 @@ const server = {
|
|
827
850
|
return totalSummary
|
828
851
|
|
829
852
|
} catch (error) {
|
830
|
-
|
853
|
+
logger.error(`Error occurred: ${error}`);
|
854
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
831
855
|
|
832
856
|
}
|
833
857
|
},
|
@@ -848,9 +872,10 @@ const server = {
|
|
848
872
|
let uniqueErrors = new Set()
|
849
873
|
|
850
874
|
|
851
|
-
|
875
|
+
const db_schema = schema
|
876
|
+
// let maxIds = await Campuses.max('_id'); = await Schedules.max('_id'); // Fetch maximum _id directly from the Schedules model
|
852
877
|
// let maxId = maxIds|| 0;
|
853
|
-
// await db.sequelize.query(`ALTER SEQUENCE
|
878
|
+
// await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Schedules__id_seq" RESTART WITH ${maxId + 1}`);
|
854
879
|
|
855
880
|
for (let i = 0; i < scheduleApi.length; i++){
|
856
881
|
try {
|
@@ -923,7 +948,8 @@ const server = {
|
|
923
948
|
}
|
924
949
|
|
925
950
|
} catch (error) {
|
926
|
-
|
951
|
+
logger.error(`Error occurred: ${error}`);
|
952
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
927
953
|
}
|
928
954
|
}
|
929
955
|
|
@@ -945,7 +971,8 @@ const server = {
|
|
945
971
|
return totalSummary
|
946
972
|
|
947
973
|
} catch (error) {
|
948
|
-
|
974
|
+
logger.error(`Error occurred: ${error}`);
|
975
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
949
976
|
}
|
950
977
|
},
|
951
978
|
|
@@ -974,9 +1001,10 @@ const server = {
|
|
974
1001
|
const emailDomain = 'default.msc.edu.ph';
|
975
1002
|
|
976
1003
|
|
977
|
-
|
1004
|
+
const db_schema = schema
|
1005
|
+
// let maxIds = await Campuses.max('_id'); = await Students.max('_id'); // Fetch maximum _id directly from the Students model
|
978
1006
|
// let maxId = maxIds|| 0;
|
979
|
-
// await db.sequelize.query(`ALTER SEQUENCE
|
1007
|
+
// await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Students__id_seq" RESTART WITH ${maxId + 1}`);
|
980
1008
|
|
981
1009
|
const {data} = studentApi
|
982
1010
|
for (let i = 0; i < data.length; i++){
|
@@ -1048,7 +1076,8 @@ const server = {
|
|
1048
1076
|
}
|
1049
1077
|
|
1050
1078
|
} catch (error) {
|
1051
|
-
|
1079
|
+
logger.error(`Error occurred: ${error}`);
|
1080
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
1052
1081
|
}
|
1053
1082
|
}
|
1054
1083
|
|
@@ -1070,7 +1099,8 @@ const server = {
|
|
1070
1099
|
return totalSummary
|
1071
1100
|
|
1072
1101
|
} catch (error) {
|
1073
|
-
|
1102
|
+
logger.error(`Error occurred: ${error}`);
|
1103
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
1074
1104
|
|
1075
1105
|
}
|
1076
1106
|
},
|
@@ -1104,9 +1134,10 @@ const server = {
|
|
1104
1134
|
let uniqueErrors = new Set()
|
1105
1135
|
|
1106
1136
|
|
1107
|
-
|
1137
|
+
const db_schema = schema
|
1138
|
+
// let maxIds = await Campuses.max('_id'); = await Sections.max('_id'); // Fetch maximum _id directly from the Sections model
|
1108
1139
|
// let maxId = maxIds|| 0;
|
1109
|
-
// await db.sequelize.query(`ALTER SEQUENCE
|
1140
|
+
// await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Sections__id_seq" RESTART WITH ${maxId + 1}`);
|
1110
1141
|
|
1111
1142
|
|
1112
1143
|
for (let i = 0; i < student.length; i++) {
|
@@ -1187,6 +1218,7 @@ const server = {
|
|
1187
1218
|
// campusId: _campus?._id??null,
|
1188
1219
|
// modifiedById,
|
1189
1220
|
// createdById,
|
1221
|
+
|
1190
1222
|
}
|
1191
1223
|
});
|
1192
1224
|
|
@@ -1205,7 +1237,8 @@ const server = {
|
|
1205
1237
|
}
|
1206
1238
|
}
|
1207
1239
|
} catch (error) {
|
1208
|
-
|
1240
|
+
logger.error(`Error occurred: ${error}`);
|
1241
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
1209
1242
|
}
|
1210
1243
|
}
|
1211
1244
|
|
@@ -1227,7 +1260,8 @@ const server = {
|
|
1227
1260
|
return totalSummary;
|
1228
1261
|
|
1229
1262
|
} catch (error) {
|
1230
|
-
|
1263
|
+
logger.error(`Error occurred: ${error}`);
|
1264
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
1231
1265
|
}
|
1232
1266
|
},
|
1233
1267
|
|
@@ -1258,9 +1292,10 @@ const server = {
|
|
1258
1292
|
let uniqueErrors = new Set()
|
1259
1293
|
|
1260
1294
|
|
1261
|
-
|
1295
|
+
const db_schema = schema
|
1296
|
+
// let maxIds = await Campuses.max('_id'); = await EnrolledStudents.max('_id'); // Fetch maximum _id directly from the EnrolledStudents model
|
1262
1297
|
// let maxId = maxIds|| 0;
|
1263
|
-
// await db.sequelize.query(`ALTER SEQUENCE
|
1298
|
+
// await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."EnrolledStudents__id_seq" RESTART WITH ${maxId + 1}`);
|
1264
1299
|
|
1265
1300
|
|
1266
1301
|
for (let i = 0; i < studentApi.length; i++){
|
@@ -1364,7 +1399,8 @@ const server = {
|
|
1364
1399
|
}
|
1365
1400
|
}
|
1366
1401
|
} catch (error) {
|
1367
|
-
|
1402
|
+
logger.error(`Error occurred: ${error}`);
|
1403
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
1368
1404
|
}
|
1369
1405
|
}
|
1370
1406
|
|
@@ -1386,7 +1422,8 @@ const server = {
|
|
1386
1422
|
return totalSummary
|
1387
1423
|
|
1388
1424
|
} catch (error) {
|
1389
|
-
|
1425
|
+
logger.error(`Error occurred: ${error}`);
|
1426
|
+
logger.error(`Error occurred: ${error.stack || error}`);
|
1390
1427
|
|
1391
1428
|
}
|
1392
1429
|
},
|
package/models/index.js
CHANGED