diff --git a/config/locations.js b/config/locations.js index 836cd63b..38e24182 100644 --- a/config/locations.js +++ b/config/locations.js @@ -402,15 +402,15 @@ Therefore responsible citizens have mapped out all fountains of the festival hos }, bounding_box: { // osm wm-image ch-zh Brunnentrog mit Relief "Möve" https://github.com/water-fountains/proximap/issues/306 - "latMin": 47.3655, - "lngMin": 8.54524, - "latMax": 47.3656, - "lngMax": 8.54525 +// "latMin": 47.3655, +// "lngMin": 8.54524, +// "latMax": 47.3656, +// "lngMax": 8.54525 //Klusdörfli without P18 nor coordinates 47.36518, 8.568826 -// "latMin": 47.3644, -// "lngMin": 8.56875, -// "latMax": 47.3652, -// "lngMax": 8.56885 + "latMin": 47.3644, + "lngMin": 8.56875, + "latMax": 47.3652, + "lngMax": 8.56885 // Schule Friesenberg with multiple Categories // "latMin": 47.3602, // "lngMin": 8.5054, @@ -440,5 +440,7 @@ Therefore responsible citizens have mapped out all fountains of the festival hos url_template: null } }, - gak:`${process.env.GOOGLE_API_KEY}` + gak:`${process.env.GOOGLE_API_KEY}`, + CACHE_FOR_HRS_i45db: 48, + LANGS: ['en', 'de', 'fr', 'it', 'tr', 'sr'] }; diff --git a/server/api/controllers/controller.js b/server/api/controllers/controller.js index f7e4285f..eb0c976c 100644 --- a/server/api/controllers/controller.js +++ b/server/api/controllers/controller.js @@ -24,13 +24,13 @@ import {extractProcessingErrors} from "./processing-errors.controller"; import {getImageInfo,getImgsOfCat} from "../services/wikimedia.service"; const haversine = require("haversine"); const _ = require('lodash'); -import {MAX_IMG_SHOWN_IN_GALLERY, LAZY_ARTIST_NAME_LOADING_i41db, - CACHE_FOR_HRS_i45db} from "../../common/constants"; +import {MAX_IMG_SHOWN_IN_GALLERY, LAZY_ARTIST_NAME_LOADING_i41db //,CACHE_FOR_HRS_i45db + } from "../../common/constants"; // Configuration of Cache after https://www.npmjs.com/package/node-cache const cityCache = new NodeCache( { - stdTTL: 60*60*CACHE_FOR_HRS_i45db, // time till cache expires, in seconds + stdTTL: 60*60*locations.CACHE_FOR_HRS_i45db, // time till cache expires, in seconds checkperiod: 30, // how often to check for expiration, in seconds deleteOnExpire: false, // on expire, we want the cache to be recreated not deleted useClones: false // do not create a clone of the data when fetching from cache @@ -55,7 +55,7 @@ cityCache.on('expired', (key, value)=>{ generateLocationData(key) .then(fountainCollection=>{ // save newly generated fountainCollection to the cache - cityCache.set(key, fountainCollection, 60*60*CACHE_FOR_HRS_i45db); // expire after two hours + cityCache.set(key, fountainCollection, 60*60*locations.CACHE_FOR_HRS_i45db); // expire after two hours // create a reduced version of the data as well cityCache.set(key + '_essential', essenceOf(fountainCollection)); @@ -79,7 +79,7 @@ export class Controller { generateLocationData(location_code) .then(fountainCollection => { // save new data to storage - cityCache.set(location_code, fountainCollection, 60 * 60 * CACHE_FOR_HRS_i45db); // expire after two hours + cityCache.set(location_code, fountainCollection, 60 * 60 * locations.CACHE_FOR_HRS_i45db); // expire after two hours // create a reduced version of the data as well cityCache.set(location_code + '_essential', essenceOf(fountainCollection)); // also create list of processing errors (for proximap#206) @@ -119,7 +119,7 @@ export class Controller { generateLocationData(req.query.city) .then(fountainCollection => { // save new data to storage - cityCache.set(req.query.city, fountainCollection, 60*60*CACHE_FOR_HRS_i45db); + cityCache.set(req.query.city, fountainCollection, 60*60*locations.CACHE_FOR_HRS_i45db); // create a reduced version of the data as well let r_essential = essenceOf(fountainCollection); diff --git a/server/api/services/processing.service.js b/server/api/services/processing.service.js index 0ec28e92..70b33b16 100644 --- a/server/api/services/processing.service.js +++ b/server/api/services/processing.service.js @@ -9,9 +9,11 @@ const _ = require ('lodash'); import WikimediaService from './wikimedia.service'; import WikipediaService from './wikipedia.service'; import WikidataService from './wikidata.service'; +import {locations} from '../../../config/locations'; import l from '../../common/logger'; import {fountain_property_metadata} from "../../../config/fountain.properties" -import {PROP_STATUS_INFO, PROP_STATUS_OK,LAZY_ARTIST_NAME_LOADING_i41db, LANGS} from "../../common/constants"; +import {PROP_STATUS_INFO, PROP_STATUS_OK,LAZY_ARTIST_NAME_LOADING_i41db//, LANGS + } from "../../common/constants"; export function defaultCollectionEnhancement(fountainCollection,dbg, debugAll) { l.info('processing.service.js defaultCollectionEnhancement: '+dbg+' '+new Date().toISOString()); @@ -115,7 +117,7 @@ export function fillOperatorInfo(fountainCollection, dbg){ export function fillWikipediaSummary(fountain, dbg, tot, promises) { // check all languages to see if a wikipedia page is referenced let i = 0; - _.forEach(LANGS, lang =>{ + _.forEach(locations.LANGS, lang =>{ let urlParam = `wikipedia_${lang}_url`; i=i+1; const dbgHere = i+'/'+tot+' '+dbg; @@ -254,7 +256,7 @@ export function fillOutNames(fountainCollection,dbg) { } i++; if(fProps.name.value === null){ - for(let lang of LANGS){ + for(let lang of locations.LANGS){ let fPopLng = fProps[`name_${lang}`]; if(fPopLng != null && fPopLng.value !== null){ // take the first language-specific name that is not null and apply it to the default name @@ -269,7 +271,7 @@ export function fillOutNames(fountainCollection,dbg) { } // fill lang-specific names if null and if a default name exists if(fProps.name.value !== null) { - for (let lang of LANGS) { + for (let lang of locations.LANGS) { let fPopLng = fProps[`name_${lang}`]; if (fPopLng != null && fPopLng.value === null) { fPopLng.value = fProps.name.value; diff --git a/server/api/services/wikidata.service.js b/server/api/services/wikidata.service.js index 56b9a65a..77992c58 100644 --- a/server/api/services/wikidata.service.js +++ b/server/api/services/wikidata.service.js @@ -10,7 +10,8 @@ const axios = require('axios'); import { cacheAdapterEnhancer } from 'axios-extensions'; const _ = require ('lodash'); const wdk = require('wikidata-sdk'); -import {LANGS} from "../../common/constants"; +//import {LANGS} from "../../common/constants"; +import {locations} from '../../../config/locations'; // Set up caching of http requests const http = axios.create({ @@ -190,7 +191,7 @@ class WikidataService { } // Try to find a useful link // Look for Wikipedia entry in different languages - for(let lang of LANGS){ + for(let lang of locations.LANGS){ if(entity.sitelinks.hasOwnProperty(lang+'wiki')){ fountain.properties.artist_name.derived.website.url = `https://${lang}.wikipedia.org/wiki/${entity.sitelinks[lang+'wiki']}`; return fountain; diff --git a/server/api/services/wikimedia.service.js b/server/api/services/wikimedia.service.js index 80ab5834..2496bdfc 100644 --- a/server/api/services/wikimedia.service.js +++ b/server/api/services/wikimedia.service.js @@ -13,7 +13,9 @@ const axios = require ('axios'); const { ConcurrencyManager } = require("axios-concurrency"); import l from '../../common/logger'; import {PROP_STATUS_ERROR, PROP_STATUS_INFO, PROP_STATUS_OK, PROP_STATUS_WARNING, - MAX_IMG_SHOWN_IN_GALLERY, LANGS} from "../../common/constants"; + MAX_IMG_SHOWN_IN_GALLERY//, LANGS + } from "../../common/constants"; + import {locations} from '../../../config/locations'; let api = axios.create({}); @@ -30,7 +32,7 @@ class WikimediaService { getName(f) { const props = f.properties; if(props.name.value === null){ - for(let lang of LANGS){ + for(let lang of locations.LANGS){ const pL= props[`name_${lang}`]; if(null != pL && pL.value !== null){ return pL.value; diff --git a/server/common/constants.js b/server/common/constants.js index 95194404..d0012dff 100644 --- a/server/common/constants.js +++ b/server/common/constants.js @@ -14,5 +14,5 @@ export const PROP_STATUS_NOT_DEFINED = 'PROP_STATUS_NOT_DEFINED'; export const PROP_STATUS_NOT_AVAILABLE = 'PROP_STATUS_NOT_AVAILABLE'; export const MAX_IMG_SHOWN_IN_GALLERY = 50; export const LAZY_ARTIST_NAME_LOADING_i41db = true; -export const LANGS = ['en', 'de', 'fr', 'it', 'tr', 'sr']; -export const CACHE_FOR_HRS_i45db = 48; \ No newline at end of file +//export const LANGS = ['en', 'de', 'fr', 'it', 'tr', 'sr']; +//export const CACHE_FOR_HRS_i45db = 48; \ No newline at end of file