Empty set handling and date fixes
rodzic
4d87ac63a6
commit
8190f660fe
|
@ -8,12 +8,12 @@ const pool = mariadb.createPool({
|
||||||
password: process.env.DB_PASS,
|
password: process.env.DB_PASS,
|
||||||
port: process.env.DB_PORT,
|
port: process.env.DB_PORT,
|
||||||
multipleStatements: true,
|
multipleStatements: true,
|
||||||
connectionLimit: 5,
|
connectionLimit: 5
|
||||||
timezone: 'UTC',
|
/*timezone: 'UTC',
|
||||||
dateStrings: [
|
dateStrings: [
|
||||||
'DATE',
|
'DATE',
|
||||||
'DATETIME'
|
'DATETIME'
|
||||||
]
|
]*/
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ router.get("/", async (req, res, next) => {
|
||||||
|
|
||||||
// ignore time offsets
|
// ignore time offsets
|
||||||
let formattedDate = formatDate(year,month,day);
|
let formattedDate = formatDate(year,month,day);
|
||||||
|
//let formattedDate = date;
|
||||||
|
|
||||||
let conn;
|
let conn;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -60,8 +60,14 @@ router.get("/", async (req, res, next) => {
|
||||||
fh.day = day(t.fl_date)";
|
fh.day = day(t.fl_date)";
|
||||||
|
|
||||||
var results = await conn.query(query);
|
var results = await conn.query(query);
|
||||||
var analyzedResults = analyzeResults(results);
|
|
||||||
res.send(analyzedResults);
|
if (results.length > 0) {
|
||||||
|
var analyzedResults = analyzeResults(results);
|
||||||
|
res.send(analyzedResults);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res.send(results);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -116,19 +122,19 @@ function round(value, precision) {
|
||||||
// You can either tie into an existing Weather Forecast API
|
// You can either tie into an existing Weather Forecast API
|
||||||
// or provide hard-coded lookups like the following.
|
// or provide hard-coded lookups like the following.
|
||||||
var forecasts = {
|
var forecasts = {
|
||||||
"ORD_2020-02-09": {
|
"ORD_2020-02-27": {
|
||||||
description: "Snow",
|
description: "Snow",
|
||||||
icon: "snow",
|
icon: "snow",
|
||||||
temp_low: "28°F",
|
temp_low: "-2°C",
|
||||||
temp_high: "29°F",
|
temp_high: "-1°C",
|
||||||
precip_probability: 0.6,
|
precip_probability: .6,
|
||||||
wind_speed: 15
|
wind_speed: 15
|
||||||
},
|
},
|
||||||
"LAX_2020-02-11": {
|
"LAX_2020-02-28": {
|
||||||
description: "Clear",
|
description: "Clear",
|
||||||
icon: "clear-day",
|
icon: "clear-day",
|
||||||
temp_low: "56°F",
|
temp_low: "13°C",
|
||||||
temp_high: "65°F",
|
temp_high: "15°C",
|
||||||
precip_probability: 0,
|
precip_probability: 0,
|
||||||
wind_speed: 5
|
wind_speed: 5
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue