fix data order in week
Some checks failed
SimcoDash/simcompanies-dashboard/pipeline/head This commit looks good
SimcoDash/simcompanies-dashboard/pipeline/pr-master There was a failure building this commit

This commit is contained in:
2020-05-14 23:11:50 +02:00
parent 2e17dc48ca
commit 38177c6349

View File

@@ -222,10 +222,10 @@ app.get('/API/week', function (req, res) {
var querying = "";
for (let i = 0; i < 7; i++) {
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 + " 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 + " 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 + " 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);
}
connection.query(querying, function (error, results, fields) {