Changed return names according to Interfacedefinition of frontend
This commit is contained in:
parent
809951fd85
commit
ee63caf1ea
@ -1,25 +1,25 @@
|
|||||||
module.exports = async (dbConn, id) => {
|
module.exports = async (dbConn, id) => {
|
||||||
const region = await dbConn.query(
|
const region = await dbConn.query(
|
||||||
`SELECT regions.id AS region_id,
|
`SELECT regions.id AS region_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,
|
rcma.temperature_mean,
|
||||||
rcma.temperature_mean_min,
|
rcma.temperature_mean_min,
|
||||||
rcma.temperature_mean_max,
|
rcma.temperature_mean_max,
|
||||||
rcma.percipitation,
|
rcma.percipitation AS precipitation,
|
||||||
rcma.raindays,
|
rcma.raindays AS rain_days,
|
||||||
rcma.sunshine,
|
rcma.sunshine AS sun_hours,
|
||||||
rcma.humidity,
|
rcma.humidity,
|
||||||
regions_byt.average_per_day,
|
regions_byt.average_per_day AS average_per_day_costs,
|
||||||
regions_byt.accomodation,
|
regions_byt.accomodation AS accommodation_costs,
|
||||||
regions_byt.food,
|
regions_byt.food AS food_costs,
|
||||||
regions_byt.water,
|
regions_byt.water AS water_costs,
|
||||||
regions_byt.local_transportation,
|
regions_byt.local_transportation AS local_transportation_costs,
|
||||||
regions_byt.entertainment,
|
regions_byt.entertainment AS entertainment_costs,
|
||||||
regions_byt.tips_and_handouts,
|
regions_byt.tips_and_handouts AS tips_and_handouts_costs,
|
||||||
regions_byt.scams_robberies_and_mishaps,
|
regions_byt.scams_robberies_and_mishaps AS scams_robberies_and_mishaps_costs,
|
||||||
regions_byt.alcohol
|
regions_byt.alcohol AS alcohol_costs
|
||||||
FROM regions
|
FROM regions
|
||||||
JOIN countries ON regions.country_id = countries.id
|
JOIN countries ON regions.country_id = countries.id
|
||||||
JOIN (SELECT rcma.region_id,
|
JOIN (SELECT rcma.region_id,
|
||||||
@ -61,25 +61,25 @@ module.exports = async (dbConn, id) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (region[k].percipitation !== null) {
|
if (region[k].precipitation !== null) {
|
||||||
const percipitation = region[k].percipitation
|
const precipitation = region[k].precipitation
|
||||||
region[k].percipitation = percipitation.split(",");
|
region[k].precipitation = precipitation.split(",");
|
||||||
for (i = 0; i < region[k].percipitation.length; i++) {
|
for (i = 0; i < region[k].precipitation.length; i++) {
|
||||||
region[k].percipitation[i] = parseFloat(region[k].percipitation[i])
|
region[k].precipitation[i] = parseFloat(region[k].precipitation[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (region[k].raindays !== null) {
|
if (region[k].rain_days !== null) {
|
||||||
const raindays = region[k].raindays
|
const rain_days = region[k].rain_days
|
||||||
region[k].raindays = raindays.split(",");
|
region[k].rain_days = rain_days.split(",");
|
||||||
for (i = 0; i < region[k].raindays.length; i++) {
|
for (i = 0; i < region[k].rain_days.length; i++) {
|
||||||
region[k].raindays[i] = parseFloat(region[k].raindays[i])
|
region[k].rain_days[i] = parseFloat(region[k].rain_days[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (region[k].sunshine !== null) {
|
if (region[k].sun_hours !== null) {
|
||||||
const sunshine = region[k].sunshine
|
const sun_hours = region[k].sun_hours
|
||||||
region[k].sunshine = sunshine.split(",");
|
region[k].sun_hours = sun_hours.split(",");
|
||||||
for (i = 0; i < region[k].sunshine.length; i++) {
|
for (i = 0; i < region[k].sun_hours.length; i++) {
|
||||||
region[k].sunshine[i] = parseFloat(region[k].sunshine[i])
|
region[k].sun_hours[i] = parseFloat(region[k].sun_hours[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (region[k].humidity !== null) {
|
if (region[k].humidity !== null) {
|
||||||
@ -90,6 +90,6 @@ module.exports = async (dbConn, id) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return region[0];
|
return region;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
module.exports = async (dbConn) => {
|
module.exports = async (dbConn) => {
|
||||||
const regions = await dbConn.query(
|
const regions = await dbConn.query(
|
||||||
`SELECT regions.id AS region_id,
|
`SELECT regions.id AS region_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,
|
rcma.temperature_mean,
|
||||||
rcma.temperature_mean_min,
|
rcma.temperature_mean_min,
|
||||||
rcma.temperature_mean_max,
|
rcma.temperature_mean_max,
|
||||||
rcma.percipitation,
|
rcma.percipitation AS precipitation,
|
||||||
rcma.raindays,
|
rcma.raindays AS rain_days,
|
||||||
rcma.sunshine,
|
rcma.sunshine AS sun_hours,
|
||||||
rcma.humidity,
|
rcma.humidity,
|
||||||
regions_byt.average_per_day,
|
regions_byt.average_per_day AS average_per_day_costs,
|
||||||
regions_byt.accomodation,
|
regions_byt.accomodation AS accommodation_costs,
|
||||||
regions_byt.food,
|
regions_byt.food AS food_costs,
|
||||||
regions_byt.water,
|
regions_byt.water AS water_costs,
|
||||||
regions_byt.local_transportation,
|
regions_byt.local_transportation AS local_transportation_costs,
|
||||||
regions_byt.entertainment,
|
regions_byt.entertainment AS entertainment_costs,
|
||||||
regions_byt.tips_and_handouts,
|
regions_byt.tips_and_handouts AS tips_and_handouts_costs,
|
||||||
regions_byt.scams_robberies_and_mishaps,
|
regions_byt.scams_robberies_and_mishaps AS scams_robberies_and_mishaps_costs,
|
||||||
regions_byt.alcohol
|
regions_byt.alcohol AS alcohol_costs
|
||||||
FROM regions
|
FROM regions
|
||||||
JOIN countries ON regions.country_id = countries.id
|
JOIN countries ON regions.country_id = countries.id
|
||||||
JOIN (SELECT rcma.region_id,
|
JOIN (SELECT rcma.region_id,
|
||||||
@ -59,25 +59,25 @@ module.exports = async (dbConn) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (regions[k].percipitation !== null) {
|
if (regions[k].precipitation !== null) {
|
||||||
const percipitation = regions[k].percipitation
|
const precipitation = regions[k].precipitation
|
||||||
regions[k].percipitation = percipitation.split(",");
|
regions[k].precipitation = precipitation.split(",");
|
||||||
for (i = 0; i < regions[k].percipitation.length; i++) {
|
for (i = 0; i < regions[k].precipitation.length; i++) {
|
||||||
regions[k].percipitation[i] = parseFloat(regions[k].percipitation[i])
|
regions[k].precipitation[i] = parseFloat(regions[k].precipitation[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (regions[k].raindays !== null) {
|
if (regions[k].rain_days !== null) {
|
||||||
const raindays = regions[k].raindays
|
const rain_days = regions[k].rain_days
|
||||||
regions[k].raindays = raindays.split(",");
|
regions[k].rain_days = rain_days.split(",");
|
||||||
for (i = 0; i < regions[k].raindays.length; i++) {
|
for (i = 0; i < regions[k].rain_days.length; i++) {
|
||||||
regions[k].raindays[i] = parseFloat(regions[k].raindays[i])
|
regions[k].rain_days[i] = parseFloat(regions[k].rain_days[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (regions[k].sunshine !== null) {
|
if (regions[k].sun_hours !== null) {
|
||||||
const sunshine = regions[k].sunshine
|
const sun_hours = regions[k].sun_hours
|
||||||
regions[k].sunshine = sunshine.split(",");
|
regions[k].sun_hours = sun_hours.split(",");
|
||||||
for (i = 0; i < regions[k].sunshine.length; i++) {
|
for (i = 0; i < regions[k].sun_hours.length; i++) {
|
||||||
regions[k].sunshine[i] = parseFloat(regions[k].sunshine[i])
|
regions[k].sun_hours[i] = parseFloat(regions[k].sun_hours[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (regions[k].humidity !== null) {
|
if (regions[k].humidity !== null) {
|
||||||
|
|||||||
@ -1,23 +1,22 @@
|
|||||||
module.exports = async (dbConn) => {
|
module.exports = async (dbConn) => {
|
||||||
let presets = await dbConn.query(
|
let presets = await dbConn.query(
|
||||||
`SELECT search_presets.id AS country_id,
|
`SELECT search_presets.id AS preset_id,
|
||||||
search_presets.parameter AS parameter,
|
search_presets.parameter AS parameter,
|
||||||
search_presets.name AS name,
|
search_presets.name AS tag_label,
|
||||||
CASE
|
CASE
|
||||||
WHEN value_2 is NULL THEN value_1
|
WHEN value_2 is NULL THEN value_1
|
||||||
ELSE CONCAT(search_presets.value_1,"|",search_presets.value_2)
|
ELSE CONCAT(search_presets.value_1,"|",search_presets.value_2)
|
||||||
END AS "values"
|
END AS "value"
|
||||||
FROM search_presets`
|
FROM search_presets`
|
||||||
);
|
);
|
||||||
|
|
||||||
//TODO: Which way is preferred?
|
|
||||||
for (k = 0; k < presets.length; k++) {
|
for (k = 0; k < presets.length; k++) {
|
||||||
//if (presets[k].values.toString().includes("|")) {
|
//if (presets[k].values.toString().includes("|")) {
|
||||||
const values = presets[k].values
|
const value = presets[k].value
|
||||||
presets[k].values = values.split("|");
|
presets[k].value = value.split("|");
|
||||||
for (i = 0; i < presets[k].values.length; i++) {
|
for (i = 0; i < presets[k].value.length; i++) {
|
||||||
presets[k].values[i] = parseFloat(presets[k].values[i])
|
presets[k].value[i] = parseFloat(presets[k].value[i])
|
||||||
}
|
}
|
||||||
//} else {
|
//} else {
|
||||||
// presets[k].values = parseInt(presets[k].values)
|
// presets[k].values = parseInt(presets[k].values)
|
||||||
//}
|
//}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user