Merge pull request 'fix data order in week' (#64) from fix-data-order-in-week into master
All checks were successful
SimcoDash/simcompanies-dashboard/pipeline/head This commit looks good

Reviewed-by: falk <falk.ba@gmx.de>
This commit was merged in pull request #64.
This commit is contained in:
2020-05-15 00:06:02 +02:00

View File

@@ -222,10 +222,10 @@ app.get('/API/week', function (req, res) {
var querying = ""; var querying = "";
for (let i = 0; i < 7; i++) { for (let i = 0; i < 7; i++) {
let currentday = day.toMysqlFormat().split(" ")[0]; let currentday = day.toMysqlFormat().split(" ")[0];
querying += `SELECT "${currentday + " 21:00:00"}" as time,kind,quality,AVG(price) as price FROM marketv2 WHERE kind = ${kind} AND TIME > "${currentday} 18:00:00" AND TIME <= "${currentday} 23:59:59" GROUP BY kind,quality UNION `; querying += `SELECT "${currentday + " 3:00:00"}" as time,kind,quality,AVG(price) as price FROM marketv2 WHERE kind = ${kind} AND TIME > "${currentday} 00:00:00" AND TIME <= "${currentday} 05:59:59" GROUP BY kind,quality UNION `;
querying += `SELECT "${currentday + " 15:00:00"}" as time,kind,quality,AVG(price) as price FROM marketv2 WHERE kind = ${kind} AND TIME > "${currentday} 12:00:00" AND TIME <= "${currentday} 17:59:59" GROUP BY kind,quality UNION `;
querying += `SELECT "${currentday + " 09:00:00"}" as time,kind,quality,AVG(price) as price FROM marketv2 WHERE kind = ${kind} AND TIME > "${currentday} 6:00:00" AND TIME <= "${currentday} 11:59:59" GROUP BY kind,quality UNION `; querying += `SELECT "${currentday + " 09:00:00"}" as time,kind,quality,AVG(price) as price FROM marketv2 WHERE kind = ${kind} AND TIME > "${currentday} 6:00:00" AND TIME <= "${currentday} 11:59:59" GROUP BY kind,quality UNION `;
querying += `SELECT "${currentday + " 3:00:00"}" as time,kind,quality,AVG(price) as price FROM marketv2 WHERE kind = ${kind} AND TIME > "${currentday} 00:00:00" AND TIME <= "${currentday} 05:59:59" GROUP BY kind,quality ${i === 6 ? "" : "UNION"} `; querying += `SELECT "${currentday + " 15:00:00"}" as time,kind,quality,AVG(price) as price FROM marketv2 WHERE kind = ${kind} AND TIME > "${currentday} 12:00:00" AND TIME <= "${currentday} 17:59:59" GROUP BY kind,quality UNION `;
querying += `SELECT "${currentday + " 21:00:00"}" as time,kind,quality,AVG(price) as price FROM marketv2 WHERE kind = ${kind} AND TIME > "${currentday} 18:00:00" AND TIME <= "${currentday} 23:59:59" GROUP BY kind,quality ${i === 6 ? "" : "UNION"} `;
day.setDate(day.getDate() + 1); day.setDate(day.getDate() + 1);
} }
connection.query(querying, function (error, results, fields) { connection.query(querying, function (error, results, fields) {