Merge branch 'master' into add-week-month-view
This commit is contained in:
@@ -32,7 +32,7 @@ var sessionStore = new MySQLStore({
|
|||||||
|
|
||||||
const mockDataDay = require('./mockdata-test/day.json');
|
const mockDataDay = require('./mockdata-test/day.json');
|
||||||
const mockDataWeek = require('./mockdata-test/week.json');
|
const mockDataWeek = require('./mockdata-test/week.json');
|
||||||
//const mockDataMonth = require('./mockdata-test/month.json');
|
const mockDataMonth = require('./mockdata-test/month.json');
|
||||||
var resourceList;
|
var resourceList;
|
||||||
const saltRounds = 13;
|
const saltRounds = 13;
|
||||||
|
|
||||||
@@ -221,10 +221,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 id,kind,quality,AVG(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 + " 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 id,kind,quality,AVG(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 + " 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 id,kind,quality,AVG(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 + " 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 id,kind,quality,AVG(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"} `;
|
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);
|
day.setDate(day.getDate() - 1);
|
||||||
}
|
}
|
||||||
connection.query(querying, function (error, results, fields) {
|
connection.query(querying, function (error, results, fields) {
|
||||||
@@ -246,14 +246,14 @@ app.get('/API/month', function (req, res) {
|
|||||||
const kind = parseInt(req.query.kind);
|
const kind = parseInt(req.query.kind);
|
||||||
if (Number.isInteger(kind)) {
|
if (Number.isInteger(kind)) {
|
||||||
//Mock Data:
|
//Mock Data:
|
||||||
//if (kind === -1 || DEBUG) return res.send(mockDataMonth);
|
if (kind === -1 || DEBUG) return res.send(mockDataMonth);
|
||||||
|
|
||||||
if (kind >= 1 && kind <= 113) {
|
if (kind >= 1 && kind <= 113) {
|
||||||
var day = new Date();
|
var day = new Date();
|
||||||
var querying = "";
|
var querying = "";
|
||||||
for (let i = 0; i < 30; i++) {
|
for (let i = 0; i < 30; i++) {
|
||||||
let currentday = day.toMysqlFormat().split(" ")[0];
|
let currentday = day.toMysqlFormat().split(" ")[0];
|
||||||
querying += `SELECT "${currentday}" as id,kind,quality,AVG(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"} `;
|
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);
|
day.setDate(day.getDate() - 1);
|
||||||
}
|
}
|
||||||
connection.query(querying, function (error, results, fields) {
|
connection.query(querying, function (error, results, fields) {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user