Add more comments
This commit is contained in:
parent
29666babbc
commit
0ed58d6fa1
@ -1,7 +1,7 @@
|
||||
const axios = require("axios")
|
||||
const getPlacePhoto = require("./getPlacePhoto.js")
|
||||
|
||||
const fields = "photos,place_id,name,rating,geometry"
|
||||
const fields = "photos,place_id,name,rating,geometry" // Parameters for Google Place API
|
||||
|
||||
module.exports = async (q) => {
|
||||
const res = await axios.get(
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
const axios = require("axios")
|
||||
const getPlacePhoto = require("./getPlacePhoto.js")
|
||||
|
||||
const radius = 20000
|
||||
const rankby = "prominence"
|
||||
const types = "tourist_attraction"
|
||||
const radius = 20000 // Search radius in meters
|
||||
const rankby = "prominence" // Sorting of results
|
||||
const types = "tourist_attraction" // Category which shall be searched
|
||||
|
||||
module.exports = async (lat, lng) => {
|
||||
const res = await axios.get(
|
||||
|
||||
@ -1,45 +0,0 @@
|
||||
exports.getBYTdataByRegion = async (dbConn, id, travelstyle = 1) => {
|
||||
const res = await dbConn.query(
|
||||
`SELECT
|
||||
region_id,
|
||||
travelstyle,
|
||||
average_per_day AS average_per_day_costs,
|
||||
accomodation AS accommodation_costs,
|
||||
food AS food_costs,
|
||||
water AS water_costs,
|
||||
local_transportation AS local_transportation_costs,
|
||||
entertainment AS entertainment_costs
|
||||
FROM regions_byt
|
||||
WHERE region_id = ? AND travelstyle = ?`,
|
||||
[id, travelstyle]
|
||||
);
|
||||
return res;
|
||||
};
|
||||
|
||||
exports.getAllBYTdata = async (dbConn, travelstyle = 1) => {
|
||||
const res = await dbConn.query(
|
||||
`SELECT
|
||||
region_id,
|
||||
travelstyle,
|
||||
average_per_day AS average_per_day_costs,
|
||||
accomodation AS accommodation_costs,
|
||||
food AS food_costs,
|
||||
water AS water_costs,
|
||||
local_transportation AS local_transportation_costs,
|
||||
entertainment AS entertainment_costs
|
||||
FROM regions_byt
|
||||
WHERE travelstyle = ?`,
|
||||
[travelstyle]
|
||||
);
|
||||
return res;
|
||||
};
|
||||
|
||||
exports.getTrivagoData = async (dbConn, id) => {
|
||||
const region = await dbConn.query(
|
||||
`...`,
|
||||
[id]
|
||||
);
|
||||
return region;
|
||||
};
|
||||
|
||||
|
||||
@ -58,17 +58,6 @@ module.exports = async (dbConn) => {
|
||||
|
||||
|
||||
return regions.map(region => {
|
||||
/*
|
||||
const emptyArr = Array.from({ length: 12 }, () => null)
|
||||
if (region.avg_price_relative === null) region.avg_price_relative = undefined
|
||||
if (region.temperature_mean === null) region.temperature_mean = undefined
|
||||
if (region.temperature_mean_min === null) region.temperature_mean_min = undefined
|
||||
if (region.temperature_mean_max === null) region.temperature_mean_max = undefined
|
||||
if (region.precipitation === null) region.precipitation = undefined
|
||||
if (region.rain_days === null) region.rain_days = undefined
|
||||
if (region.sun_hours === null) region.sun_hours = undefined
|
||||
if (region.humidity === null) region.humidity = undefined
|
||||
*/
|
||||
region.tags = tags.filter(tag => tag.region_id === region.region_id).map(tag => {
|
||||
delete tag.region_id
|
||||
return tag
|
||||
|
||||
@ -11,15 +11,11 @@ module.exports = async (dbConn) => {
|
||||
);
|
||||
|
||||
for (k = 0; k < presets.length; k++) {
|
||||
//if (presets[k].values.toString().includes("|")) {
|
||||
const value = presets[k].value
|
||||
presets[k].value = value.split("|");
|
||||
for (i = 0; i < presets[k].value.length; i++) {
|
||||
presets[k].value[i] = parseFloat(presets[k].value[i])
|
||||
}
|
||||
//} else {
|
||||
// presets[k].values = parseInt(presets[k].values)
|
||||
//}
|
||||
}
|
||||
return presets;
|
||||
};
|
||||
@ -1,11 +1,12 @@
|
||||
const axios = require('axios')
|
||||
const _ = require('lodash')
|
||||
|
||||
// TODO: Automatically retrieve dates via aviable Data and get rid of random dates
|
||||
// Constants
|
||||
// TODO: Automatically retrieve dates via aviable Data from database and get rid of "random" dates
|
||||
const rangeStartDate = '2019-01' // If no date is given, this date will be used as startDate
|
||||
const rangeEndDate = '2020-05'// If no date is given, this date will be used as endDate
|
||||
|
||||
// TODO: call method periodically, not over API
|
||||
// TODO: call method periodically, not over API (fine for prototyping, tho)
|
||||
module.exports = async (dbConn, startDate = rangeStartDate, endDate = rangeEndDate) => {
|
||||
console.log('update climate with:', startDate, endDate);
|
||||
|
||||
@ -54,7 +55,6 @@ async function createClimateObjectFrom(src, startDate, endDate) {
|
||||
sun_hours: element.sunshine,
|
||||
humidity: element.humidity ? element.humidity : null
|
||||
}
|
||||
//console.log(result)
|
||||
return result
|
||||
})
|
||||
return retVal
|
||||
@ -62,7 +62,6 @@ async function createClimateObjectFrom(src, startDate, endDate) {
|
||||
|
||||
async function writeToDatabase(dbConn, climateObjArr) {
|
||||
for (const element of climateObjArr) {
|
||||
//console.log(element)
|
||||
try {
|
||||
await dbConn.query(`
|
||||
INSERT INTO region_climate
|
||||
|
||||
@ -2,10 +2,11 @@ const axios = require('axios')
|
||||
const _ = require('lodash')
|
||||
|
||||
// Constants
|
||||
// TODO: Automatically retrieve dates via aviable Data from database and get rid of "random" dates
|
||||
const rangeStartDate = '2019-01-01' // If no date is given, this date will be used as startDate
|
||||
const rangeEndDate = '2019-12-31'// If no date is given, this date will be used as endDate
|
||||
|
||||
// TODO: call method periodically, not over API
|
||||
// TODO: call method periodically, not over API (fine for prototyping, tho)
|
||||
module.exports = async (dbConn, startDate = rangeStartDate, endDate = rangeEndDate) => {
|
||||
console.log('update climate with:', startDate, endDate);
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const axios = require("axios")
|
||||
const getRegions = require("../models/getRegions.js")
|
||||
|
||||
const fields = "geometry"
|
||||
const fields = "geometry" // Parameters for Google Places API
|
||||
|
||||
module.exports = async (dbConn) => {
|
||||
const regions = await getRegions(dbConn)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user