Small fix according to database col name change
This commit is contained in:
parent
724ebfe35c
commit
961760601d
@ -6,10 +6,13 @@ module.exports = async (dbConn, id) => {
|
|||||||
regions.region AS name,
|
regions.region AS name,
|
||||||
countries.country AS country,
|
countries.country AS country,
|
||||||
regions.description AS description,
|
regions.description AS description,
|
||||||
|
rcma.temperature_mean AS temperature_mean,
|
||||||
|
rcma.temperature_mean_min AS temperature_mean_min,
|
||||||
rcma.temperature_mean_max AS temperature_mean_max,
|
rcma.temperature_mean_max AS temperature_mean_max,
|
||||||
rcma.precipitation AS precipitation,
|
rcma.precipitation AS precipitation,
|
||||||
rcma.rain_days AS rain_days,
|
rcma.rain_days AS rain_days,
|
||||||
rcma.sun_hours AS sun_hours,
|
rcma.sun_hours AS sun_hours,
|
||||||
|
rcma.humidity AS humidity,
|
||||||
regions_byt.average_per_day_costs AS average_per_day_costs,
|
regions_byt.average_per_day_costs AS average_per_day_costs,
|
||||||
rtma.avg_price_relative AS avg_price_relative,
|
rtma.avg_price_relative AS avg_price_relative,
|
||||||
regions_byt.accommodation_costs AS accommodation_costs,
|
regions_byt.accommodation_costs AS accommodation_costs,
|
||||||
@ -43,19 +46,24 @@ module.exports = async (dbConn, id) => {
|
|||||||
|
|
||||||
for (k = 0; k < region.length; k++) {
|
for (k = 0; k < region.length; k++) {
|
||||||
region[k].avg_price_relative = arrayFormatting(region[k].avg_price_relative);
|
region[k].avg_price_relative = arrayFormatting(region[k].avg_price_relative);
|
||||||
//region[k].temperature_mean = arrayFormatting(region[k].temperature_mean);
|
region[k].temperature_mean = arrayFormatting(region[k].temperature_mean);
|
||||||
//region[k].temperature_mean_min = arrayFormatting(region[k].temperature_mean_min);
|
region[k].temperature_mean_min = arrayFormatting(region[k].temperature_mean_min);
|
||||||
region[k].temperature_mean_max = arrayFormatting(region[k].temperature_mean_max);
|
region[k].temperature_mean_max = arrayFormatting(region[k].temperature_mean_max);
|
||||||
region[k].precipitation = arrayFormatting(region[k].precipitation);
|
region[k].precipitation = arrayFormatting(region[k].precipitation);
|
||||||
region[k].rain_days = arrayFormatting(region[k].rain_days);
|
region[k].rain_days = arrayFormatting(region[k].rain_days);
|
||||||
region[k].sun_hours = arrayFormatting(region[k].sun_hours);
|
region[k].sun_hours = arrayFormatting(region[k].sun_hours);
|
||||||
//region[k].humidity = arrayFormatting(region[k].humidity);
|
region[k].humidity = arrayFormatting(region[k].humidity);
|
||||||
}
|
}
|
||||||
const emptyArr = Array.from({ length: 12 }, () => null)
|
const emptyArr = Array.from({ length: 12 }, () => null)
|
||||||
|
if (region.avg_price_relative === null) region.avg_price_relative = emptyArr
|
||||||
|
if (region.temperature_mean === null) region.temperature_mean = emptyArr
|
||||||
|
if (region.temperature_mean_min === null) region.temperature_mean_min = emptyArr
|
||||||
|
if (region.temperature_mean_max === null) region.temperature_mean_max = emptyArr
|
||||||
if (region.temperature_mean_max === null) region.temperature_mean_max = emptyArr
|
if (region.temperature_mean_max === null) region.temperature_mean_max = emptyArr
|
||||||
if (region.precipitation === null) region.precipitation = emptyArr
|
if (region.precipitation === null) region.precipitation = emptyArr
|
||||||
if (region.rain_days === null) region.rain_days = emptyArr
|
if (region.rain_days === null) region.rain_days = emptyArr
|
||||||
if (region.sun_hours === null) region.sun_hours = emptyArr
|
if (region.sun_hours === null) region.sun_hours = emptyArr
|
||||||
|
if (region.humidity === null) region.humidity = emptyArr
|
||||||
return region;
|
return region;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -7,10 +7,13 @@ module.exports = async (dbConn) => {
|
|||||||
regions.region AS name,
|
regions.region AS name,
|
||||||
countries.country AS country,
|
countries.country AS country,
|
||||||
regions.description AS description,
|
regions.description AS description,
|
||||||
|
rcma.temperature_mean AS temperature_mean,
|
||||||
|
rcma.temperature_mean_min AS temperature_mean_min,
|
||||||
rcma.temperature_mean_max AS temperature_mean_max,
|
rcma.temperature_mean_max AS temperature_mean_max,
|
||||||
rcma.precipitation AS precipitation,
|
rcma.precipitation AS precipitation,
|
||||||
rcma.rain_days AS rain_days,
|
rcma.rain_days AS rain_days,
|
||||||
rcma.sun_hours AS sun_hours,
|
rcma.sun_hours AS sun_hours,
|
||||||
|
rcma.humidity AS humidity,
|
||||||
regions_byt.average_per_day_costs AS average_per_day_costs,
|
regions_byt.average_per_day_costs AS average_per_day_costs,
|
||||||
rtma.avg_price_relative AS avg_price_relative,
|
rtma.avg_price_relative AS avg_price_relative,
|
||||||
regions_byt.accommodation_costs AS accommodation_costs,
|
regions_byt.accommodation_costs AS accommodation_costs,
|
||||||
@ -42,22 +45,26 @@ module.exports = async (dbConn) => {
|
|||||||
|
|
||||||
for (k = 0; k < regions.length; k++) {
|
for (k = 0; k < regions.length; k++) {
|
||||||
regions[k].avg_price_relative = arrayFormatting(regions[k].avg_price_relative);
|
regions[k].avg_price_relative = arrayFormatting(regions[k].avg_price_relative);
|
||||||
//regions[k].temperature_mean = arrayFormatting(regions[k].temperature_mean);
|
regions[k].temperature_mean = arrayFormatting(regions[k].temperature_mean);
|
||||||
//regions[k].temperature_mean_min = arrayFormatting(regions[k].temperature_mean_min);
|
regions[k].temperature_mean_min = arrayFormatting(regions[k].temperature_mean_min);
|
||||||
regions[k].temperature_mean_max = arrayFormatting(regions[k].temperature_mean_max);
|
regions[k].temperature_mean_max = arrayFormatting(regions[k].temperature_mean_max);
|
||||||
regions[k].precipitation = arrayFormatting(regions[k].precipitation);
|
regions[k].precipitation = arrayFormatting(regions[k].precipitation);
|
||||||
regions[k].rain_days = arrayFormatting(regions[k].rain_days);
|
regions[k].rain_days = arrayFormatting(regions[k].rain_days);
|
||||||
regions[k].sun_hours = arrayFormatting(regions[k].sun_hours);
|
regions[k].sun_hours = arrayFormatting(regions[k].sun_hours);
|
||||||
//regions[k].humidity = arrayFormatting(regions[k].humidity);
|
regions[k].humidity = arrayFormatting(regions[k].humidity);
|
||||||
|
|
||||||
}
|
}
|
||||||
//console.log(regions.filter(region => region.rain_days === null))
|
//console.log(regions.filter(region => region.rain_days === null))
|
||||||
return regions.map(region => {
|
return regions.map(region => {
|
||||||
const emptyArr = Array.from({ length: 12 }, () => null)
|
const emptyArr = Array.from({ length: 12 }, () => null)
|
||||||
|
if (region.avg_price_relative === null) region.avg_price_relative = emptyArr
|
||||||
|
if (region.temperature_mean === null) region.temperature_mean = emptyArr
|
||||||
|
if (region.temperature_mean_min === null) region.temperature_mean_min = emptyArr
|
||||||
if (region.temperature_mean_max === null) region.temperature_mean_max = emptyArr
|
if (region.temperature_mean_max === null) region.temperature_mean_max = emptyArr
|
||||||
if (region.precipitation === null) region.precipitation = emptyArr
|
if (region.precipitation === null) region.precipitation = emptyArr
|
||||||
if (region.rain_days === null) region.rain_days = emptyArr
|
if (region.rain_days === null) region.rain_days = emptyArr
|
||||||
if (region.sun_hours === null) region.sun_hours = emptyArr
|
if (region.sun_hours === null) region.sun_hours = emptyArr
|
||||||
|
if (region.humidity === null) region.humidity = emptyArr
|
||||||
return region
|
return region
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,16 +5,16 @@ exports.getClimateMinMax = async function (dbConn) {
|
|||||||
MIN(temperature_mean_min) AS temperature_mean_min,
|
MIN(temperature_mean_min) AS temperature_mean_min,
|
||||||
MIN(temperature_mean_max) AS temperature_mean_max,
|
MIN(temperature_mean_max) AS temperature_mean_max,
|
||||||
MIN(precipitation) AS precipitation,
|
MIN(precipitation) AS precipitation,
|
||||||
MIN(raindays) AS rain_days,
|
MIN(rain_days) AS rain_days,
|
||||||
MIN(sunshine) AS sun_hours
|
MIN(sun_hours) AS sun_hours
|
||||||
FROM region_climate`
|
FROM region_climate`
|
||||||
const sqlMax = `SELECT
|
const sqlMax = `SELECT
|
||||||
MAX(temperature_mean) AS temperature_mean,
|
MAX(temperature_mean) AS temperature_mean,
|
||||||
MAX(temperature_mean_min) AS temperature_mean_min,
|
MAX(temperature_mean_min) AS temperature_mean_min,
|
||||||
MAX(temperature_mean_max) AS temperature_mean_max,
|
MAX(temperature_mean_max) AS temperature_mean_max,
|
||||||
MAX(precipitation) AS precipitation,
|
MAX(precipitation) AS precipitation,
|
||||||
MAX(raindays) AS rain_days,
|
MAX(rain_days) AS rain_days,
|
||||||
MAX(sunshine) AS sun_hours
|
MAX(sun_hours) AS sun_hours
|
||||||
FROM region_climate`
|
FROM region_climate`
|
||||||
const [qResMin, qResMax] = await Promise.all([dbConn.query(sqlMin), dbConn.query(sqlMax)])
|
const [qResMin, qResMax] = await Promise.all([dbConn.query(sqlMin), dbConn.query(sqlMax)])
|
||||||
// console.log(qResMin)
|
// console.log(qResMin)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user