fixed empty climate arrays in regions
This commit is contained in:
parent
e88952388b
commit
7e919026e7
@ -23,7 +23,7 @@ module.exports = async (dbConn, id) => {
|
||||
GROUP_CONCAT(IFNULL(rcma.temperature_mean,"") ORDER BY rcma.month SEPARATOR ', ') AS temperature_mean,
|
||||
GROUP_CONCAT(IFNULL(rcma.temperature_mean_min, "") ORDER BY rcma.month SEPARATOR ', ') AS temperature_mean_min,
|
||||
GROUP_CONCAT(IFNULL(rcma.temperature_mean_max, "") ORDER BY rcma.month SEPARATOR ', ') AS temperature_mean_max,
|
||||
GROUP_CONCAT(IFNULL(rcma.percipitation, "") ORDER BY rcma.month SEPARATOR ', ') AS precipitation,
|
||||
GROUP_CONCAT(IFNULL(rcma.precipitation, "") ORDER BY rcma.month SEPARATOR ', ') AS precipitation,
|
||||
GROUP_CONCAT(IFNULL(rcma.raindays, "") ORDER BY rcma.month SEPARATOR ', ') AS raindays,
|
||||
GROUP_CONCAT(IFNULL(rcma.sunshine, "") ORDER BY rcma.month SEPARATOR ', ') AS sunshine,
|
||||
GROUP_CONCAT(IFNULL(rcma.humidity, "") ORDER BY rcma.month SEPARATOR ', ') AS humidity
|
||||
@ -44,6 +44,11 @@ module.exports = async (dbConn, id) => {
|
||||
region[k].sun_hours = climateArrayFormatting(region[k].sun_hours);
|
||||
//region[k].humidity = climateArrayFormatting(region[k].humidity);
|
||||
}
|
||||
const emptyArr = Array.from({ length: 12 }, () => null)
|
||||
if (region.temperature_mean_max === null) region.temperature_mean_max = emptyArr
|
||||
if (region.precipitation === null) region.precipitation = emptyArr
|
||||
if (region.rain_days === null) region.rain_days = emptyArr
|
||||
if (region.sun_hours === null) region.sun_hours = emptyArr
|
||||
return region;
|
||||
};
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
const climateArrayFormatting = require("./../util/climateArrayFormatting.js")
|
||||
const climateArrayFormatting = require("./../util/climateArrayFormatting.js");
|
||||
const { takeRightWhile } = require("lodash");
|
||||
|
||||
module.exports = async (dbConn) => {
|
||||
const regions = await dbConn.query(
|
||||
@ -23,7 +24,7 @@ module.exports = async (dbConn) => {
|
||||
GROUP_CONCAT(IFNULL(rcma.temperature_mean,"") ORDER BY rcma.month SEPARATOR ', ') AS temperature_mean,
|
||||
GROUP_CONCAT(IFNULL(rcma.temperature_mean_min, "") ORDER BY rcma.month SEPARATOR ', ') AS temperature_mean_min,
|
||||
GROUP_CONCAT(IFNULL(rcma.temperature_mean_max, "") ORDER BY rcma.month SEPARATOR ', ') AS temperature_mean_max,
|
||||
GROUP_CONCAT(IFNULL(rcma.percipitation, "") ORDER BY rcma.month SEPARATOR ', ') AS precipitation,
|
||||
GROUP_CONCAT(IFNULL(rcma.precipitation, "") ORDER BY rcma.month SEPARATOR ', ') AS precipitation,
|
||||
GROUP_CONCAT(IFNULL(rcma.raindays, "") ORDER BY rcma.month SEPARATOR ', ') AS raindays,
|
||||
GROUP_CONCAT(IFNULL(rcma.sunshine, "") ORDER BY rcma.month SEPARATOR ', ') AS sunshine,
|
||||
GROUP_CONCAT(IFNULL(rcma.humidity, "") ORDER BY rcma.month SEPARATOR ', ') AS humidity
|
||||
@ -41,7 +42,16 @@ module.exports = async (dbConn) => {
|
||||
regions[k].rain_days = climateArrayFormatting(regions[k].rain_days);
|
||||
regions[k].sun_hours = climateArrayFormatting(regions[k].sun_hours);
|
||||
//regions[k].humidity = climateArrayFormatting(regions[k].humidity);
|
||||
|
||||
}
|
||||
return regions;
|
||||
console.log(regions.filter(region => region.rain_days === null))
|
||||
return regions.map(region => {
|
||||
const emptyArr = Array.from({ length: 12 }, () => null)
|
||||
if (region.temperature_mean_max === null) region.temperature_mean_max = emptyArr
|
||||
if (region.precipitation === null) region.precipitation = emptyArr
|
||||
if (region.rain_days === null) region.rain_days = emptyArr
|
||||
if (region.sun_hours === null) region.sun_hours = emptyArr
|
||||
return region
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user