@neutron.co.id/pendidikan-operation 1.26.31-beta.1 → 1.26.31
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/build/actions/akademik/updateReportStudent/updateReportStudent.action.cjs +0 -3
- package/build/actions/akademik/updateReportStudent/updateReportStudent.action.mjs +0 -3
- package/build/providers/data/useImportData.cjs +15 -0
- package/build/providers/data/useImportData.mjs +15 -0
- package/package.json +4 -4
|
@@ -14,7 +14,6 @@ const updateReportStudent = operation.Action.define({
|
|
|
14
14
|
execute: async (input, stream) => {
|
|
15
15
|
utils.guard(stream, "streamRequired");
|
|
16
16
|
utils.guard(input, "inputRequired");
|
|
17
|
-
console.log("masuk");
|
|
18
17
|
return useTelemetry.useTelemetry(stream, "updateStudentReport", {
|
|
19
18
|
userId: stream.context.identitas.userId,
|
|
20
19
|
...input
|
|
@@ -23,8 +22,6 @@ const updateReportStudent = operation.Action.define({
|
|
|
23
22
|
const data = validate(input);
|
|
24
23
|
const dbs = stream.core.dbs;
|
|
25
24
|
const dbStudent = dbs["neu-akademik"].models["neu:akademik:student"];
|
|
26
|
-
console.log("data", data);
|
|
27
|
-
console.log("dbStudent", dbStudent);
|
|
28
25
|
await dbStudent.findOneAndUpdate(
|
|
29
26
|
{ _id: data.studentId },
|
|
30
27
|
{
|
|
@@ -12,7 +12,6 @@ const updateReportStudent = Action.define({
|
|
|
12
12
|
execute: async (input, stream) => {
|
|
13
13
|
guard(stream, "streamRequired");
|
|
14
14
|
guard(input, "inputRequired");
|
|
15
|
-
console.log("masuk");
|
|
16
15
|
return useTelemetry(stream, "updateStudentReport", {
|
|
17
16
|
userId: stream.context.identitas.userId,
|
|
18
17
|
...input
|
|
@@ -21,8 +20,6 @@ const updateReportStudent = Action.define({
|
|
|
21
20
|
const data = validate(input);
|
|
22
21
|
const dbs = stream.core.dbs;
|
|
23
22
|
const dbStudent = dbs["neu-akademik"].models["neu:akademik:student"];
|
|
24
|
-
console.log("data", data);
|
|
25
|
-
console.log("dbStudent", dbStudent);
|
|
26
23
|
await dbStudent.findOneAndUpdate(
|
|
27
24
|
{ _id: data.studentId },
|
|
28
25
|
{
|
|
@@ -9,9 +9,24 @@ function useImportData(stream) {
|
|
|
9
9
|
utils.guard(stream, "streamRequired");
|
|
10
10
|
async function prepareGradingMapper(stream2, input) {
|
|
11
11
|
utils.guard(stream2, "streamRequired");
|
|
12
|
+
const allStudentsFound = await validateAllGradingsHaveStudent(stream2, input.datas);
|
|
13
|
+
if (!allStudentsFound) {
|
|
14
|
+
throw new Error("Import failed: Some gradings do not match any student.");
|
|
15
|
+
}
|
|
12
16
|
void queueArrayInChunks(stream2, input.datas, 100, processBatch);
|
|
13
17
|
return { status: "CSV has being processed" };
|
|
14
18
|
}
|
|
19
|
+
async function validateAllGradingsHaveStudent(stream2, gradings) {
|
|
20
|
+
const studentMap = await findStudentsByIdsAndNis(stream2, gradings);
|
|
21
|
+
for (const grading of gradings) {
|
|
22
|
+
const found = studentMap.get(grading.userId) || studentMap.get(grading.nis) || studentMap.get(grading.stageId) || studentMap.get(grading.branchId);
|
|
23
|
+
if (!found) {
|
|
24
|
+
console.warn(`\u274C Student not found for grading: ${JSON.stringify(grading.userId)}`);
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
15
30
|
async function _gradingMapper(stream2, input) {
|
|
16
31
|
const operations = [];
|
|
17
32
|
const validGradings = input.gradings.filter((grading) => grading?.userId);
|
|
@@ -7,9 +7,24 @@ function useImportData(stream) {
|
|
|
7
7
|
guard(stream, "streamRequired");
|
|
8
8
|
async function prepareGradingMapper(stream2, input) {
|
|
9
9
|
guard(stream2, "streamRequired");
|
|
10
|
+
const allStudentsFound = await validateAllGradingsHaveStudent(stream2, input.datas);
|
|
11
|
+
if (!allStudentsFound) {
|
|
12
|
+
throw new Error("Import failed: Some gradings do not match any student.");
|
|
13
|
+
}
|
|
10
14
|
void queueArrayInChunks(stream2, input.datas, 100, processBatch);
|
|
11
15
|
return { status: "CSV has being processed" };
|
|
12
16
|
}
|
|
17
|
+
async function validateAllGradingsHaveStudent(stream2, gradings) {
|
|
18
|
+
const studentMap = await findStudentsByIdsAndNis(stream2, gradings);
|
|
19
|
+
for (const grading of gradings) {
|
|
20
|
+
const found = studentMap.get(grading.userId) || studentMap.get(grading.nis) || studentMap.get(grading.stageId) || studentMap.get(grading.branchId);
|
|
21
|
+
if (!found) {
|
|
22
|
+
console.warn(`\u274C Student not found for grading: ${JSON.stringify(grading.userId)}`);
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
13
28
|
async function _gradingMapper(stream2, input) {
|
|
14
29
|
const operations = [];
|
|
15
30
|
const validGradings = input.gradings.filter((grading) => grading?.userId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neutron.co.id/pendidikan-operation",
|
|
3
|
-
"version": "1.26.31
|
|
3
|
+
"version": "1.26.31",
|
|
4
4
|
"description": "Operation package of Neutron Pendidikan.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"contributors": [
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@neon.id/types": "^1.69.0",
|
|
40
40
|
"@neon.id/utils": "^1.52.0",
|
|
41
41
|
"@neon.id/z": "^1.16.0",
|
|
42
|
-
"@neutron.co.id/akademik-models": "^1.20.1
|
|
42
|
+
"@neutron.co.id/akademik-models": "^1.20.1",
|
|
43
43
|
"@neutron.co.id/jadwal-models": "^1.19.11",
|
|
44
44
|
"@neutron.co.id/pendidikan-types": "^1.22.23-beta.1",
|
|
45
45
|
"@neutron.co.id/penilaian-models": "^1.17.8",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@neon.id/types": "^1.69.0",
|
|
76
76
|
"@neon.id/utils": "^1.52.0",
|
|
77
77
|
"@neon.id/z": "^1.16.0",
|
|
78
|
-
"@neutron.co.id/akademik-models": "^1.20.1
|
|
78
|
+
"@neutron.co.id/akademik-models": "^1.20.1",
|
|
79
79
|
"@neutron.co.id/jadwal-models": "^1.19.11",
|
|
80
80
|
"@neutron.co.id/pendidikan-types": "^1.22.23-beta.1",
|
|
81
81
|
"@neutron.co.id/penilaian-models": "^1.17.8",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
88
88
|
},
|
|
89
|
-
"build":
|
|
89
|
+
"build": 122
|
|
90
90
|
}
|