Add more comments

This commit is contained in:
Timo John 2020-07-10 15:35:38 +02:00
parent 29666babbc
commit 0ed58d6fa1
8 changed files with 10 additions and 70 deletions

View File

@ -1,7 +1,7 @@
const axios = require("axios") const axios = require("axios")
const getPlacePhoto = require("./getPlacePhoto.js") 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) => { module.exports = async (q) => {
const res = await axios.get( const res = await axios.get(

View File

@ -1,9 +1,9 @@
const axios = require("axios") const axios = require("axios")
const getPlacePhoto = require("./getPlacePhoto.js") const getPlacePhoto = require("./getPlacePhoto.js")
const radius = 20000 const radius = 20000 // Search radius in meters
const rankby = "prominence" const rankby = "prominence" // Sorting of results
const types = "tourist_attraction" const types = "tourist_attraction" // Category which shall be searched
module.exports = async (lat, lng) => { module.exports = async (lat, lng) => {
const res = await axios.get( const res = await axios.get(

View File

@ -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;
};

View File

@ -58,17 +58,6 @@ module.exports = async (dbConn) => {
return regions.map(region => { 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 => { region.tags = tags.filter(tag => tag.region_id === region.region_id).map(tag => {
delete tag.region_id delete tag.region_id
return tag return tag

View File

@ -11,15 +11,11 @@ module.exports = async (dbConn) => {
); );
for (k = 0; k < presets.length; k++) { for (k = 0; k < presets.length; k++) {
//if (presets[k].values.toString().includes("|")) {
const value = presets[k].value const value = presets[k].value
presets[k].value = value.split("|"); presets[k].value = value.split("|");
for (i = 0; i < presets[k].value.length; i++) { for (i = 0; i < presets[k].value.length; i++) {
presets[k].value[i] = parseFloat(presets[k].value[i]) presets[k].value[i] = parseFloat(presets[k].value[i])
} }
//} else {
// presets[k].values = parseInt(presets[k].values)
//}
} }
return presets; return presets;
}; };

View File

@ -1,11 +1,12 @@
const axios = require('axios') const axios = require('axios')
const _ = require('lodash') 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 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 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) => { module.exports = async (dbConn, startDate = rangeStartDate, endDate = rangeEndDate) => {
console.log('update climate with:', startDate, endDate); console.log('update climate with:', startDate, endDate);
@ -54,7 +55,6 @@ async function createClimateObjectFrom(src, startDate, endDate) {
sun_hours: element.sunshine, sun_hours: element.sunshine,
humidity: element.humidity ? element.humidity : null humidity: element.humidity ? element.humidity : null
} }
//console.log(result)
return result return result
}) })
return retVal return retVal
@ -62,7 +62,6 @@ async function createClimateObjectFrom(src, startDate, endDate) {
async function writeToDatabase(dbConn, climateObjArr) { async function writeToDatabase(dbConn, climateObjArr) {
for (const element of climateObjArr) { for (const element of climateObjArr) {
//console.log(element)
try { try {
await dbConn.query(` await dbConn.query(`
INSERT INTO region_climate INSERT INTO region_climate

View File

@ -2,10 +2,11 @@ const axios = require('axios')
const _ = require('lodash') const _ = require('lodash')
// Constants // 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 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 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) => { module.exports = async (dbConn, startDate = rangeStartDate, endDate = rangeEndDate) => {
console.log('update climate with:', startDate, endDate); console.log('update climate with:', startDate, endDate);

View File

@ -1,7 +1,7 @@
const axios = require("axios") const axios = require("axios")
const getRegions = require("../models/getRegions.js") const getRegions = require("../models/getRegions.js")
const fields = "geometry" const fields = "geometry" // Parameters for Google Places API
module.exports = async (dbConn) => { module.exports = async (dbConn) => {
const regions = await getRegions(dbConn) const regions = await getRegions(dbConn)