bugfix backend return correct kind
All checks were successful
SimcoDash/simcompanies-dashboard/pipeline/head This commit looks good
All checks were successful
SimcoDash/simcompanies-dashboard/pipeline/head This commit looks good
bugfix change order for graph display
This commit is contained in:
@@ -218,14 +218,15 @@ app.get('/API/week', function (req, res) {
|
||||
|
||||
if (kind >= 1 && kind <= 113) {
|
||||
var day = new Date();
|
||||
day.setDate(day.getDate() - 6)
|
||||
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 = 1 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 = 1 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 = 1 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 = 1 AND TIME > "${currentday} 00:00:00" AND TIME <= "${currentday} 05:59:59" GROUP BY kind,quality ${i === 6 ? "" : "UNION"} `;
|
||||
day.setDate(day.getDate() - 1);
|
||||
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 + " 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"} `;
|
||||
day.setDate(day.getDate() + 1);
|
||||
}
|
||||
connection.query(querying, function (error, results, fields) {
|
||||
if (error) {
|
||||
@@ -250,11 +251,12 @@ app.get('/API/month', function (req, res) {
|
||||
|
||||
if (kind >= 1 && kind <= 113) {
|
||||
var day = new Date();
|
||||
day.setDate(day.getDate() - 29);
|
||||
var querying = "";
|
||||
for (let i = 0; i < 30; i++) {
|
||||
let currentday = day.toMysqlFormat().split(" ")[0];
|
||||
querying += `SELECT "${currentday}" as time,kind,quality,AVG(price) as price FROM marketv2 WHERE kind = 1 AND TIME >= "${currentday} 00:00:00" AND TIME <= "${currentday} 23:59:59" GROUP BY kind,quality ${i === 29 ? "" : "UNION"} `;
|
||||
day.setDate(day.getDate() - 1);
|
||||
querying += `SELECT "${currentday}" as time,kind,quality,AVG(price) as price FROM marketv2 WHERE kind = ${kind} AND TIME >= "${currentday} 00:00:00" AND TIME <= "${currentday} 23:59:59" GROUP BY kind,quality ${i === 29 ? "" : "UNION"} `;
|
||||
day.setDate(day.getDate() + 1);
|
||||
}
|
||||
connection.query(querying, function (error, results, fields) {
|
||||
if (error) {
|
||||
|
||||
Reference in New Issue
Block a user