lms-sync 1.0.10 → 1.0.12
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/apiConnects.js +2 -2
- package/apiConnections/mapping.js +119 -65
- package/apiConnections/tablePick.js +80 -0
- package/app.js +2 -2
- package/package.json +1 -1
@@ -227,7 +227,7 @@ const Apis = {
|
|
227
227
|
},
|
228
228
|
}
|
229
229
|
)
|
230
|
-
console.log('student.data :>> ', student.data);
|
230
|
+
// console.log('student.data :>> ', student.data);
|
231
231
|
return student.data
|
232
232
|
} catch (error) {
|
233
233
|
console.error('Student Api Error:', error);
|
@@ -251,7 +251,7 @@ const Apis = {
|
|
251
251
|
},
|
252
252
|
}
|
253
253
|
)
|
254
|
-
console.log('sectionResult.data :>> ', sectionResult.data);
|
254
|
+
// console.log('sectionResult.data :>> ', sectionResult.data);
|
255
255
|
return sectionResult.data
|
256
256
|
} catch (error) {
|
257
257
|
console.error('Student Api Error:', error);
|
@@ -2,6 +2,8 @@ const db = require('../models')
|
|
2
2
|
const logger = require('../utils/logger')
|
3
3
|
const api = require('../apiConnections/apiConnects')
|
4
4
|
const moment = require('moment')
|
5
|
+
const { Picked } = require('./semesterPick')
|
6
|
+
|
5
7
|
const {
|
6
8
|
AcademicDepartments,
|
7
9
|
AcademicYears,
|
@@ -37,6 +39,10 @@ const server = {
|
|
37
39
|
let errorCounter = 0
|
38
40
|
let uniqueErrors = new Set()
|
39
41
|
|
42
|
+
// let maxIds = await Campuses.max('_id'); // Fetch maximum _id directly from the campuses model
|
43
|
+
// let maxId = maxIds|| 0;
|
44
|
+
// await db.sequelize.query(`ALTER SEQUENCE public_migrations."Campuses__id_seq" RESTART WITH ${maxId + 1}`);
|
45
|
+
|
40
46
|
for (let i = 0; i < campusApi.length; i++){
|
41
47
|
try {
|
42
48
|
|
@@ -62,9 +68,9 @@ const server = {
|
|
62
68
|
createdCounter++;
|
63
69
|
}
|
64
70
|
else {
|
65
|
-
const errorMsg = `Record campus already exists [${record.code}] - ${record.name} `;
|
71
|
+
const errorMsg = `Record campus already exists: [${record.code}] - ${record.name} `;
|
66
72
|
if (!uniqueErrors.has(errorMsg)) {
|
67
|
-
logger.error(`${errorCounter + 1}/${errorCounter + 1}
|
73
|
+
logger.error(`${errorCounter + 1}/${errorCounter + 1} ${errorMsg}`);
|
68
74
|
uniqueErrors.add(errorMsg);
|
69
75
|
errorCounter++;
|
70
76
|
}
|
@@ -117,6 +123,10 @@ const server = {
|
|
117
123
|
let errorCounter = 0
|
118
124
|
let uniqueErrors = new Set()
|
119
125
|
|
126
|
+
// let maxIds = await Colleges.max('_id'); // Fetch maximum _id directly from the Colleges model
|
127
|
+
// let maxId = maxIds|| 0;
|
128
|
+
// await db.sequelize.query(`ALTER SEQUENCE public_migrations."Colleges__id_seq" RESTART WITH ${maxId + 1}`);
|
129
|
+
|
120
130
|
for (let i = 0; i < collegeApi.length; i++){
|
121
131
|
try {
|
122
132
|
let _college = collegeApi[i]
|
@@ -150,7 +160,7 @@ const server = {
|
|
150
160
|
const errorMsg = `Record college already exists: [${record.code}] - ${record.name} `
|
151
161
|
|
152
162
|
if (!uniqueErrors.has(errorMsg)) {
|
153
|
-
logger.error(`${errorCounter + 1}/${errorCounter + 1}
|
163
|
+
logger.error(`${errorCounter + 1}/${errorCounter + 1} ${errorMsg}`);
|
154
164
|
uniqueErrors.add(errorMsg);
|
155
165
|
errorCounter++;
|
156
166
|
}
|
@@ -205,6 +215,9 @@ const server = {
|
|
205
215
|
let errorCounter = 0
|
206
216
|
let uniqueErrors = new Set()
|
207
217
|
|
218
|
+
// let maxIds = await AcademicDepartments.max('_id'); // Fetch maximum _id directly from the AcademicDepartments model
|
219
|
+
// let maxId = maxIds|| 0;
|
220
|
+
// await db.sequelize.query(`ALTER SEQUENCE public_migrations."AcademicDepartments__id_seq" RESTART WITH ${maxId + 1}`);
|
208
221
|
for (let i = 0; i < departmentApi.length; i++){
|
209
222
|
try {
|
210
223
|
let _acadDept = departmentApi[i]
|
@@ -245,10 +258,10 @@ const server = {
|
|
245
258
|
createdCounter++;
|
246
259
|
}
|
247
260
|
else {
|
248
|
-
const errorMsg = `Record academic department already exists [${record.code}] - ${record.name} `
|
261
|
+
const errorMsg = `Record academic department already exists: [${record.code}] - ${record.name} `
|
249
262
|
|
250
263
|
if (!uniqueErrors.has(errorMsg)) {
|
251
|
-
logger.error(`${errorCounter + 1}/${errorCounter + 1}
|
264
|
+
logger.error(`${errorCounter + 1}/${errorCounter + 1} ${errorMsg}`);
|
252
265
|
uniqueErrors.add(errorMsg);
|
253
266
|
errorCounter++;
|
254
267
|
}
|
@@ -306,6 +319,10 @@ const server = {
|
|
306
319
|
let errorCounter = 0
|
307
320
|
let uniqueErrors = new Set()
|
308
321
|
|
322
|
+
// let maxIds = await Courses.max('_id'); // Fetch maximum _id directly from the Courses model
|
323
|
+
// let maxId = maxIds|| 0;
|
324
|
+
// await db.sequelize.query(`ALTER SEQUENCE public_migrations."Courses__id_seq" RESTART WITH ${maxId + 1}`);
|
325
|
+
|
309
326
|
for (let i = 0; i < studentApi.length; i++){
|
310
327
|
try {
|
311
328
|
|
@@ -346,10 +363,10 @@ const server = {
|
|
346
363
|
createdCounter++
|
347
364
|
} else {
|
348
365
|
|
349
|
-
const errorMsg = `Record course already exists [${record.code}] - ${record.name}, Major in ${record.major}`;
|
366
|
+
const errorMsg = `Record course already exists: [${record.code}] - ${record.name}, Major in ${record.major}`;
|
350
367
|
|
351
368
|
if (!uniqueErrors.has(errorMsg)) {
|
352
|
-
logger.error(`${errorCounter + 1}/${errorCounter + 1}
|
369
|
+
logger.error(`${errorCounter + 1}/${errorCounter + 1} ${errorMsg}`);
|
353
370
|
uniqueErrors.add(errorMsg);
|
354
371
|
errorCounter++;
|
355
372
|
}
|
@@ -408,6 +425,12 @@ const server = {
|
|
408
425
|
let errorCounter = 0
|
409
426
|
let uniqueErrors = new Set()
|
410
427
|
|
428
|
+
|
429
|
+
// let maxIds = await Rooms.max('_id'); // Fetch maximum _id directly from the Rooms model
|
430
|
+
// let maxId = maxIds|| 0;
|
431
|
+
// await db.sequelize.query(`ALTER SEQUENCE public_migrations."Rooms__id_seq" RESTART WITH ${maxId + 1}`);
|
432
|
+
|
433
|
+
|
411
434
|
for (let i = 0; i < roomApi.length; i++){
|
412
435
|
try {
|
413
436
|
let _room = roomApi[i]
|
@@ -455,10 +478,10 @@ const server = {
|
|
455
478
|
createdCounter++;
|
456
479
|
}
|
457
480
|
else {
|
458
|
-
const errorMsg = `Record room already exists ${record.name}`;
|
481
|
+
const errorMsg = `Record room already exists: ${record.name}`;
|
459
482
|
|
460
483
|
if (!uniqueErrors.has(errorMsg)) {
|
461
|
-
logger.error(`${errorCounter + 1}/${errorCounter + 1}
|
484
|
+
logger.error(`${errorCounter + 1}/${errorCounter + 1} ${errorMsg}`);
|
462
485
|
uniqueErrors.add(errorMsg);
|
463
486
|
errorCounter++;
|
464
487
|
}
|
@@ -512,6 +535,12 @@ const server = {
|
|
512
535
|
let errorCounter = 0
|
513
536
|
let uniqueErrors = new Set()
|
514
537
|
|
538
|
+
|
539
|
+
// let maxIds = await Instructors.max('_id'); // Fetch maximum _id directly from the Instructors model
|
540
|
+
// let maxId = maxIds|| 0;
|
541
|
+
// await db.sequelize.query(`ALTER SEQUENCE public_migrations."Instructors__id_seq" RESTART WITH ${maxId + 1}`);
|
542
|
+
|
543
|
+
|
515
544
|
for (let i = 0; i < instructorApi.length; i++){
|
516
545
|
try {
|
517
546
|
let _instructor = instructorApi[i]
|
@@ -554,10 +583,10 @@ const server = {
|
|
554
583
|
createdCounter++;
|
555
584
|
}
|
556
585
|
else {
|
557
|
-
const errorMsg = `Record instructor already exists [${record.employeeNumber}] - ${record.lastName}, ${record.firstName}`;
|
586
|
+
const errorMsg = `Record instructor already exists: [${record.employeeNumber}] - ${record.lastName}, ${record.firstName}`;
|
558
587
|
|
559
588
|
if (!uniqueErrors.has(errorMsg)) {
|
560
|
-
logger.error(`${errorCounter + 1}/${errorCounter + 1}
|
589
|
+
logger.error(`${errorCounter + 1}/${errorCounter + 1} ${errorMsg}`);
|
561
590
|
uniqueErrors.add(errorMsg);
|
562
591
|
errorCounter++;
|
563
592
|
}
|
@@ -609,6 +638,12 @@ const server = {
|
|
609
638
|
|
610
639
|
const { acadYearResult, currentSchoolYear } = acadYearApi;
|
611
640
|
|
641
|
+
|
642
|
+
// let maxIds = await AcademicYears.max('_id'); // Fetch maximum _id directly from the AcademicYears model
|
643
|
+
// let maxId = maxIds|| 0;
|
644
|
+
// await db.sequelize.query(`ALTER SEQUENCE public_migrations."AcademicYears__id_seq" RESTART WITH ${maxId + 1}`);
|
645
|
+
|
646
|
+
|
612
647
|
for (let i = 0; i < acadYearResult.length; i++){
|
613
648
|
try {
|
614
649
|
let _acadyear = acadYearResult[i]
|
@@ -645,9 +680,9 @@ const server = {
|
|
645
680
|
createdCounter++;
|
646
681
|
}
|
647
682
|
else {
|
648
|
-
const errorMsg = `Record academic year already exists ${record.from} - ${record.to}`;
|
683
|
+
const errorMsg = `Record academic year already exists: ${record.from} - ${record.to}`;
|
649
684
|
if (!uniqueErrors.has(errorMsg)) {
|
650
|
-
logger.error(`${errorCounter + 1}/${errorCounter + 1}
|
685
|
+
logger.error(`${errorCounter + 1}/${errorCounter + 1} ${errorMsg}`);
|
651
686
|
uniqueErrors.add(errorMsg);
|
652
687
|
errorCounter++;
|
653
688
|
}
|
@@ -700,6 +735,12 @@ const server = {
|
|
700
735
|
let errorCounter = 0
|
701
736
|
let uniqueErrors = new Set()
|
702
737
|
|
738
|
+
|
739
|
+
// let maxIds = await Subjects.max('_id'); // Fetch maximum _id directly from the Subjects model
|
740
|
+
// let maxId = maxIds|| 0;
|
741
|
+
// await db.sequelize.query(`ALTER SEQUENCE public_migrations."Subjects__id_seq" RESTART WITH ${maxId + 1}`);
|
742
|
+
|
743
|
+
|
703
744
|
for (let i = 0; i < studentSubject.length; i++){
|
704
745
|
try {
|
705
746
|
let _subject = studentSubject[i]
|
@@ -752,10 +793,10 @@ const server = {
|
|
752
793
|
createdCounter++;
|
753
794
|
}
|
754
795
|
else {
|
755
|
-
const errorMsg = `Record subject already exists [${record.code}], ${record.name}`;
|
796
|
+
const errorMsg = `Record subject already exists: [${record.code}], ${record.name}`;
|
756
797
|
|
757
798
|
if (!uniqueErrors.has(errorMsg)) {
|
758
|
-
logger.error(`${errorCounter + 1}/${errorCounter + 1}
|
799
|
+
logger.error(`${errorCounter + 1}/${errorCounter + 1} ${errorMsg}`);
|
759
800
|
uniqueErrors.add(errorMsg);
|
760
801
|
errorCounter++;
|
761
802
|
}
|
@@ -806,6 +847,11 @@ const server = {
|
|
806
847
|
let errorCounter = 0
|
807
848
|
let uniqueErrors = new Set()
|
808
849
|
|
850
|
+
|
851
|
+
// let maxIds = await Schedules.max('_id'); // Fetch maximum _id directly from the Schedules model
|
852
|
+
// let maxId = maxIds|| 0;
|
853
|
+
// await db.sequelize.query(`ALTER SEQUENCE public_migrations."Schedules__id_seq" RESTART WITH ${maxId + 1}`);
|
854
|
+
|
809
855
|
for (let i = 0; i < scheduleApi.length; i++){
|
810
856
|
try {
|
811
857
|
let _schedule = scheduleApi[i]
|
@@ -867,10 +913,10 @@ const server = {
|
|
867
913
|
createdCounter++;
|
868
914
|
}
|
869
915
|
else {
|
870
|
-
const errorMsg = `Record schedule already exists [${record.from} - ${record.to}] ${record.name}`;
|
916
|
+
const errorMsg = `Record schedule already exists: [${record.from} - ${record.to}] ${record.name}`;
|
871
917
|
|
872
918
|
if (!uniqueErrors.has(errorMsg)) {
|
873
|
-
logger.error(`${errorCounter + 1}/${errorCounter + 1}
|
919
|
+
logger.error(`${errorCounter + 1}/${errorCounter + 1} ${errorMsg}`);
|
874
920
|
uniqueErrors.add(errorMsg);
|
875
921
|
errorCounter++;
|
876
922
|
}
|
@@ -928,6 +974,10 @@ const server = {
|
|
928
974
|
const emailDomain = 'default.msc.edu.ph';
|
929
975
|
|
930
976
|
|
977
|
+
// let maxIds = await Students.max('_id'); // Fetch maximum _id directly from the Students model
|
978
|
+
// let maxId = maxIds|| 0;
|
979
|
+
// await db.sequelize.query(`ALTER SEQUENCE public_migrations."Students__id_seq" RESTART WITH ${maxId + 1}`);
|
980
|
+
|
931
981
|
const {data} = studentApi
|
932
982
|
for (let i = 0; i < data.length; i++){
|
933
983
|
try {
|
@@ -950,18 +1000,19 @@ const server = {
|
|
950
1000
|
let courseDefault = 999999
|
951
1001
|
let collegeDefault = 999999
|
952
1002
|
|
953
|
-
let semester = "2nd Semester"
|
954
|
-
let _semester = semesterSeq.find(sem => sem.code === semester)
|
955
|
-
|
956
|
-
let acadFrom = 2023
|
957
|
-
let acadTo = 2024
|
958
|
-
|
959
|
-
|
960
1003
|
|
1004
|
+
let fromPrompts = await Picked()
|
1005
|
+
|
961
1006
|
|
1007
|
+
// let semester = "2nd Semester"
|
1008
|
+
let semester = fromPrompts.semester
|
1009
|
+
let yearsFrom = fromPrompts.yearFrom
|
1010
|
+
let yearsTo = fromPrompts.yearTo
|
962
1011
|
|
963
|
-
let
|
1012
|
+
let _semester = semesterSeq.find(sem => sem.code === semester)
|
1013
|
+
let _acadYear = acadYearSeq.find(yr => yr.from === parseInt(yearsFrom) && yr.to === parseInt(yearsTo))
|
964
1014
|
|
1015
|
+
// return
|
965
1016
|
let [record, created] = await Students.findOrCreate({
|
966
1017
|
where:{
|
967
1018
|
studentNumber: _student?.student_number,
|
@@ -986,10 +1037,10 @@ const server = {
|
|
986
1037
|
}
|
987
1038
|
else {
|
988
1039
|
|
989
|
-
const errorMsg = `Record student already exists [${record.studentNumber}] ${record.lastName}, ${record.firstName} ${record.middleName}`;
|
1040
|
+
const errorMsg = `Record student already exists: [${record.studentNumber}] ${record.lastName}, ${record.firstName} ${record.middleName}`;
|
990
1041
|
|
991
1042
|
if (!uniqueErrors.has(errorMsg)) {
|
992
|
-
logger.error(`${errorCounter + 1}/${errorCounter + 1}
|
1043
|
+
logger.error(`${errorCounter + 1}/${errorCounter + 1} ${errorMsg}`);
|
993
1044
|
uniqueErrors.add(errorMsg);
|
994
1045
|
errorCounter++;
|
995
1046
|
}
|
@@ -1052,6 +1103,12 @@ const server = {
|
|
1052
1103
|
let errorCounter = 0
|
1053
1104
|
let uniqueErrors = new Set()
|
1054
1105
|
|
1106
|
+
|
1107
|
+
// let maxIds = await Sections.max('_id'); // Fetch maximum _id directly from the Sections model
|
1108
|
+
// let maxId = maxIds|| 0;
|
1109
|
+
// await db.sequelize.query(`ALTER SEQUENCE public_migrations."Sections__id_seq" RESTART WITH ${maxId + 1}`);
|
1110
|
+
|
1111
|
+
|
1055
1112
|
for (let i = 0; i < student.length; i++) {
|
1056
1113
|
try {
|
1057
1114
|
|
@@ -1088,21 +1145,16 @@ const server = {
|
|
1088
1145
|
continue;
|
1089
1146
|
}
|
1090
1147
|
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
1148
|
let code = sections ?? 'CODE'
|
1095
1149
|
code = code.split(/\s+/).map((word) => word.charAt(0).toUpperCase()).join('')
|
1096
1150
|
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
let _acadYear = acadYearSeq.find(yr => yr.from === acadFrom && yr.to === acadTo)
|
1151
|
+
let fromPrompts = await Picked()
|
1152
|
+
let semester = fromPrompts.semester
|
1153
|
+
let yearsFrom = fromPrompts.yearFrom
|
1154
|
+
let yearsTo = fromPrompts.yearTo
|
1155
|
+
let _semester = semesterSeq.find(sem => sem.code === semester)
|
1156
|
+
let _acadYear = acadYearSeq.find(yr => yr.from === parseInt(yearsFrom) && yr.to === parseInt(yearsTo))
|
1104
1157
|
|
1105
|
-
|
1106
1158
|
let modifiedById = userMail._id;
|
1107
1159
|
let createdById = userMail._id;
|
1108
1160
|
|
@@ -1143,10 +1195,10 @@ const server = {
|
|
1143
1195
|
createdCounter++;
|
1144
1196
|
} else {
|
1145
1197
|
|
1146
|
-
const errorMsg = `Record section already exists ${record.name} `;
|
1198
|
+
const errorMsg = `Record section already exists: ${record.name} `;
|
1147
1199
|
|
1148
1200
|
if (!uniqueErrors.has(errorMsg)) {
|
1149
|
-
logger.error(`${errorCounter + 1}/${errorCounter + 1}
|
1201
|
+
logger.error(`${errorCounter + 1}/${errorCounter + 1} ${errorMsg}`);
|
1150
1202
|
uniqueErrors.add(errorMsg);
|
1151
1203
|
errorCounter++;
|
1152
1204
|
}
|
@@ -1205,6 +1257,12 @@ const server = {
|
|
1205
1257
|
let errorCounter = 0
|
1206
1258
|
let uniqueErrors = new Set()
|
1207
1259
|
|
1260
|
+
|
1261
|
+
// let maxIds = await EnrolledStudents.max('_id'); // Fetch maximum _id directly from the EnrolledStudents model
|
1262
|
+
// let maxId = maxIds|| 0;
|
1263
|
+
// await db.sequelize.query(`ALTER SEQUENCE public_migrations."EnrolledStudents__id_seq" RESTART WITH ${maxId + 1}`);
|
1264
|
+
|
1265
|
+
|
1208
1266
|
for (let i = 0; i < studentApi.length; i++){
|
1209
1267
|
try {
|
1210
1268
|
|
@@ -1217,12 +1275,14 @@ const server = {
|
|
1217
1275
|
|
1218
1276
|
let _students = studentApi[i].subjects_enrolled
|
1219
1277
|
|
1220
|
-
let
|
1278
|
+
let fromPrompts = await Picked()
|
1279
|
+
|
1280
|
+
let semester = fromPrompts.semester
|
1281
|
+
let yearsFrom = fromPrompts.yearFrom
|
1282
|
+
let yearsTo = fromPrompts.yearTo
|
1221
1283
|
let _semester = semesterSeq.find(sem => sem.code === semester)
|
1284
|
+
let _acadYear = acadYearSeq.find(yr => yr.from === parseInt(yearsFrom) && yr.to === parseInt(yearsTo))
|
1222
1285
|
|
1223
|
-
let acadFrom = 2023
|
1224
|
-
let acadTo = 2024
|
1225
|
-
let _acadYear = acadYearSeq.find(yr => yr.from === acadFrom && yr.to === acadTo)
|
1226
1286
|
|
1227
1287
|
let modifiedById = userMail._id;
|
1228
1288
|
let createdById = userMail._id;
|
@@ -1294,10 +1354,10 @@ const server = {
|
|
1294
1354
|
createdCounter++;
|
1295
1355
|
} else {
|
1296
1356
|
|
1297
|
-
const errorMsg = `Record enrolled student already exists studentId = [${record.studentId}], sectionId = [${record.sectionId}], instructorId = [${record.instructorId}]`;
|
1357
|
+
const errorMsg = `Record enrolled student already exists: studentId = [${record.studentId}], sectionId = [${record.sectionId}], instructorId = [${record.instructorId}]`;
|
1298
1358
|
|
1299
1359
|
if (!uniqueErrors.has(errorMsg)) {
|
1300
|
-
logger.error(`${errorCounter + 1}/${errorCounter + 1}
|
1360
|
+
logger.error(`${errorCounter + 1}/${errorCounter + 1} ${errorMsg}`);
|
1301
1361
|
uniqueErrors.add(errorMsg);
|
1302
1362
|
errorCounter++;
|
1303
1363
|
}
|
@@ -1330,23 +1390,6 @@ const server = {
|
|
1330
1390
|
|
1331
1391
|
}
|
1332
1392
|
},
|
1333
|
-
|
1334
|
-
|
1335
|
-
async executeAll(){
|
1336
|
-
await this.Campus()
|
1337
|
-
await this.College()
|
1338
|
-
await this.AcademicDepartment()
|
1339
|
-
await this.Course()
|
1340
|
-
await this.Room()
|
1341
|
-
await this.Instructor()
|
1342
|
-
await this.AcademicYear()
|
1343
|
-
await this.Subject()
|
1344
|
-
await this.Schedule()
|
1345
|
-
await this.Student()
|
1346
|
-
await this.Section()
|
1347
|
-
await this.EnrolledStudent()
|
1348
|
-
|
1349
|
-
}
|
1350
1393
|
}
|
1351
1394
|
|
1352
1395
|
async function runServerFunctions() {
|
@@ -1385,7 +1428,18 @@ async function runServerFunctions() {
|
|
1385
1428
|
// module.exports = server
|
1386
1429
|
|
1387
1430
|
module.exports = {
|
1431
|
+
serverTable: server,
|
1432
|
+
Campus: server.Campus,
|
1433
|
+
College: server.College,
|
1434
|
+
AcademicDepartments: server.AcademicDepartment,
|
1435
|
+
Course: server.Course,
|
1436
|
+
Room: server.Room,
|
1437
|
+
Instructor: server.Instructor,
|
1438
|
+
AcademicYear: server.AcademicYear,
|
1439
|
+
Subject: server.Subject,
|
1440
|
+
Schedule: server.Schedule,
|
1441
|
+
Student: server.Student,
|
1442
|
+
Section: server.Section,
|
1443
|
+
EnrolledStudent: server.EnrolledStudent,
|
1388
1444
|
Server: runServerFunctions,
|
1389
|
-
Enrolled: server.EnrolledStudent,
|
1390
|
-
Section: server.Section
|
1391
1445
|
}
|
@@ -0,0 +1,80 @@
|
|
1
|
+
const prompts = require('prompts')
|
2
|
+
const mappings = require('./mapping')
|
3
|
+
|
4
|
+
let picker = null;
|
5
|
+
|
6
|
+
async function promptYearSem() {
|
7
|
+
const response = await prompts([
|
8
|
+
{
|
9
|
+
type: 'select',
|
10
|
+
name: 'Table',
|
11
|
+
message: 'Please Select Table:',
|
12
|
+
choices: [
|
13
|
+
{ title: 'All Tables', value: 'AllTables' },
|
14
|
+
{ title: 'Campus', value: 'Campus' },
|
15
|
+
{ title: 'College', value: 'College' },
|
16
|
+
{ title: 'AcademicDepartments', value: 'AcademicDepartments' },
|
17
|
+
{ title: 'Course', value: 'Course' },
|
18
|
+
{ title: 'Room', value: 'Room' },
|
19
|
+
{ title: 'Instructor', value: 'Instructor' },
|
20
|
+
{ title: 'AcademicYear', value: 'AcademicYear' },
|
21
|
+
{ title: 'Subject', value: 'Subject' },
|
22
|
+
{ title: 'Schedule', value: 'Schedule' },
|
23
|
+
{ title: 'Student', value: 'Student' },
|
24
|
+
{ title: 'Section', value: 'Section' },
|
25
|
+
{ title: 'EnrolledStudent', value: 'EnrolledStudent' },
|
26
|
+
],
|
27
|
+
initial: 0
|
28
|
+
}
|
29
|
+
]);
|
30
|
+
|
31
|
+
picker = {
|
32
|
+
table: response.Table,
|
33
|
+
};
|
34
|
+
}
|
35
|
+
|
36
|
+
async function Tables() {
|
37
|
+
try {
|
38
|
+
while (true) {
|
39
|
+
if (!picker) {
|
40
|
+
await promptYearSem()
|
41
|
+
}
|
42
|
+
|
43
|
+
let pickTable = picker
|
44
|
+
|
45
|
+
if (pickTable.table === 'AllTables') {
|
46
|
+
await mappings.Server()
|
47
|
+
} else {
|
48
|
+
await mappings[pickTable.table]()
|
49
|
+
}
|
50
|
+
|
51
|
+
console.log('\nMigration completed for the selected table.')
|
52
|
+
|
53
|
+
picker = null // reset picker after completing the migration
|
54
|
+
|
55
|
+
const response = await prompts([
|
56
|
+
{
|
57
|
+
type: 'confirm',
|
58
|
+
name: 'continue',
|
59
|
+
message: 'Do you want to pick another table?',
|
60
|
+
choices:[
|
61
|
+
{title: 'Yes', value: 'yes'},
|
62
|
+
{title: 'No', value: 'no'}
|
63
|
+
],
|
64
|
+
initial: true
|
65
|
+
}
|
66
|
+
])
|
67
|
+
|
68
|
+
if (!response.continue) {
|
69
|
+
break; // ex the loop if the user doesn't want to continue
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
} catch (error) {
|
74
|
+
console.error(error);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
module.exports = {
|
79
|
+
Tables
|
80
|
+
}
|
package/app.js
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
const sequelizeStart = require('./apiConnections/sequelizeConnection');
|
4
4
|
const apiConnects = require('./apiConnections/apiConnects')
|
5
|
-
const mappings = require('./apiConnections/mapping');
|
6
5
|
const picks = require('./apiConnections/semesterPick')
|
6
|
+
const tables = require('./apiConnections/tablePick')
|
7
7
|
|
8
8
|
async function start(){
|
9
9
|
try {
|
@@ -25,7 +25,7 @@ async function start(){
|
|
25
25
|
|
26
26
|
if(apis && startSequel){
|
27
27
|
console.log('Both connections successful. Starting migrations...');
|
28
|
-
await
|
28
|
+
const tablesPick = await tables.Tables()
|
29
29
|
}
|
30
30
|
else {
|
31
31
|
console.error('Failed to establish database and api connections. Migrations not started.');
|