-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeeder_county.js
144 lines (140 loc) · 6.15 KB
/
feeder_county.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
const statesJson = require("./states.json");
const countiesJson = require("./counties.json");
const axios = require("axios");
const paranaIdebJson = require("./ideb-pr/out.json");
const sereJson = require("../cm.json");
axios.defaults.headers.post["Content-Type"] =
"application/x-www-form-urlencoded";
function feedCounties() {
statesJson.forEach(async state => {
if (state.id == "41") {
// console.log(Object.keys(paranaIdebJson['PARANÁ']));
counties = countiesJson
.filter(v => {
return v.state_id === state.id;
})
.forEach(county => {
let county_id;
county.name = county.name
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toUpperCase();
axios
.post(
"http://localhost:3000/api/profile/county-institutional",
county
)
.then(res => {
// console.log(res.data.data.id);
county_id = res.data.data.id;
schools = paranaIdebJson["PARANÁ"][county.name];
if (schools && county.name === "CAMPO MOURAO") { /* && county.name !== "CAMPO MOURAO" */
console.log(county.name + "<<<")
schoolsNames = Object.keys(schools);
schoolsNames.forEach(async element => {
// console.log(element);
axios
.post(
"http://localhost:3000/api/profile/school-institutional", {
inep_properties: schools[element],
county_id: county_id,
name: element
}
)
.then(resSchool => {
// console.log("SchoolId " + resSchool.data.id_profile);
})
.catch(err => {
// console.error(err);
});
});
}
// else
// if (county.name === "CAMPO MOURAO") {
// console.log(county_id);
// console.log("Campo Mourão >>>");
// let escolas = sereJson["escolas"];
// escolas.forEach(escola => {
// console.log(escola["nome"]);
// axios
// .post(
// "http://localhost:3000/api/profile/school-institutional",
// {
// // inep_properties: {},
// county_id: county_id,
// name: escola["nome"]
// }
// )
// .then(
// resSchool => {
// // console.log(resSchool.data);
// turmas = escola["turmas"];
// turmas.forEach(turma => {
// let id = Object.keys(turma);
// // console.log(id);
// let infos = turma[id]["infos"];
// if (infos) {
// axios
// .post("http://localhost:3000/api/classroom", {
// school: resSchool.data.data.id_profile,
// external_id: escola["codigo"],
// course: infos["Curso"],
// shift: infos["Turno"],
// subClass: infos["Turma"],
// series: infos["Seriação"],
// hour: infos["Horário"]
// })
// .then(function(response) {
// // console.log(response.data);
// // let students = turma[id]["alunos"];
// // students.forEach(student => {
// // axios
// // .post(
// // "http://localhost:3000/api/enrollment/externalfeed",
// // {
// // classroom:
// // response.data.data.classroom._id,
// // enrollment: student
// // }
// // )
// // .then(function(response) {
// // // console.log(response.data);
// // })
// // .catch(function(error) {
// // console.log(error);
// // });
// // });
// setTimeout(function() {}, 1500);
// })
// .catch(function(error) {
// axios
// .get(
// "http://localhost:3000/api/profile/school-institutional"
// )
// .then(res => {
// console.log(res.data.data);
// })
// .catch(err => {
// console.log(">>>>>>>");
// console.log(err);
// });
// // console.log("Catch Classroom >>>>>> ");
// });
// } else {
// console.log("Classroom empty");
// }
// });
// },
// err => {
// console.log("Catch School >>>>>>>>>");
// // console.error(err);
// }
// );
// });
// }
});
});
}
});
}
feedCounties();