· 8 years ago · Mar 20, 2018, 02:24 PM
1events.forEach(function (event) {
2 // Simple date formatting
3 dayFormatted = event.day.split("_");
4 year = dayFormatted[0];
5 month = dayFormatted[1];
6 day = dayFormatted[2];
7
8 // Check if the row already exists ...
9 SQLCheckTableRow(`day`, year.toString(), month.toString(), day.toString()).then(function (skip) {
10 // ... if not it skips all this part
11 if (!skip) {
12 // Create, if it doesn't exist already, a date table that is going to be connected to all the events and fill it
13 SQLFillTable(`date, `null, "${year}" , "${month}" , "${day}", null`).then(function () {
14 let values = []
15 event.ons.forEach(function (on) {
16 on.states.forEach(function (event) {
17 values = [];
18 values.push(Object.keys(event.data).map(function (key) {
19 return event.data[key];
20 }));
21
22 SQLFillTable(`event`, values).then();
23 })
24 })
25 })
26 }
27 })
28 })