module.exports = function (dbConn) { return async function getAllRegionsWithClimatePerMonth(month) { console.log('getAllRegionsWithClimatePerMonth') const sql = `SELECT region_climate.region_id AS region_id, countries.country AS country, regions.region AS name, ROUND(AVG(region_climate.temperature_mean), 1) AS temperature_mean, ROUND(AVG(region_climate.temperature_mean_min), 1) AS temperature_mean_min, ROUND(AVG(region_climate.temperature_mean_max), 1) AS temperature_mean_max, ROUND(AVG(region_climate.percipitation), 1) AS percipitation, ROUND(AVG(region_climate.raindays), 1) AS raindays, ROUND(AVG(region_climate.sunshine), 1) AS sunhours FROM region_climate JOIN regions ON region_climate.region_id = regions.id JOIN countries ON regions.country_id = countries.id WHERE region_climate.month = ${month} GROUP BY region_id` let response = await dbConn.query(sql) console.log(response[0]); return response } }