From 0d82ef4b1a3a4ef522d1f77d7cfa7049bf7155d1 Mon Sep 17 00:00:00 2001 From: Ralf Hauser Date: Sun, 15 Dec 2019 08:49:08 +0100 Subject: [PATCH] https://github.com/water-fountains/datablue/issues/39 --- server/api/services/processing.service.js | 10 +++++----- server/api/services/wikidata.service.js | 4 ++-- server/api/services/wikimedia.service.js | 2 ++ server/api/services/wikipedia.service.js | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/server/api/services/processing.service.js b/server/api/services/processing.service.js index 69192849..ec43f3f2 100644 --- a/server/api/services/processing.service.js +++ b/server/api/services/processing.service.js @@ -19,7 +19,7 @@ export function defaultCollectionEnhancement(fountainCollection,dbg) { return new Promise((resolve, reject)=>{ fillImageGalleries(fountainCollection,dbg) .then(r => fillOutNames(r)) - .then(r => fillWikipediaSummaries(r)) + .then(r => fillWikipediaSummaries(r,dbg)) .then(r => fillArtistNames(r,dbg)) .then(r => fillOperatorInfo(r)) .then(r => resolve(r)) @@ -68,14 +68,14 @@ export function fillArtistNames(fountainCollection,dbg){ } // created for proximap #149 -export function fillOperatorInfo(fountainCollection){ +export function fillOperatorInfo(fountainCollection, dbg){ // takes a collection of fountains and returns the same collection, // enhanced with operator information if that information is available in Wikidata return new Promise((resolve, reject) => { let promises = []; _.forEach(fountainCollection, fountain =>{ - promises.push(WikidataService.fillOperatorInfo(fountain)); + promises.push(WikidataService.fillOperatorInfo(fountain,dbg)); }); Promise.all(promises) @@ -85,7 +85,7 @@ export function fillOperatorInfo(fountainCollection){ }) } -export function fillWikipediaSummaries(fountainCollection){ +export function fillWikipediaSummaries(fountainCollection, dbg){ // takes a collection of fountains and returns the same collection, enhanced with wikipedia summaries return new Promise((resolve, reject) => { let promises = []; @@ -97,7 +97,7 @@ export function fillWikipediaSummaries(fountainCollection){ if(!_.isNull(fountain.properties[urlParam].value)){ // if not Null, get summary and create new property promises.push(new Promise((resolve, reject) => { - WikipediaService.getSummary(fountain.properties[urlParam].value) + WikipediaService.getSummary(fountain.properties[urlParam].value, dbg) .then(summary => { // add suumary as derived information to url property fountain.properties[urlParam].derived = { diff --git a/server/api/services/wikidata.service.js b/server/api/services/wikidata.service.js index d9fdcde8..4c738507 100644 --- a/server/api/services/wikidata.service.js +++ b/server/api/services/wikidata.service.js @@ -212,7 +212,7 @@ class WikidataService { } - fillOperatorInfo(fountain){ + fillOperatorInfo(fountain, dbg){ // created for proximap/#149 if(fountain.properties.operator_name.source === 'wikidata'){ // create sparql url to fetch operator information from QID @@ -260,7 +260,7 @@ class WikidataService { return fountain; }) .catch(err=>{ - l.error(`Error collecting operator info name: ${err}`); + l.error(`Error collecting operator info name: ${err} `+dbg); fountain.properties.operator_name.value = fountain.properties.operator_name.value + '(lookup unsuccessful)'; return fountain}); }else{ diff --git a/server/api/services/wikimedia.service.js b/server/api/services/wikimedia.service.js index f576bbed..df7d5d8e 100644 --- a/server/api/services/wikimedia.service.js +++ b/server/api/services/wikimedia.service.js @@ -80,6 +80,8 @@ class WikimediaService { let ext = page.title.slice(-3).toLowerCase(); if( ['jpg', 'png', 'gif'].indexOf(ext)>=0){ gallery_image_promises.push(this.getImageInfo(page.title,"f-"+dbg+"_i-"+cI+"/"+cTot)); + } else { + l.info('skipping "'+page.title+'"'); } }); diff --git a/server/api/services/wikipedia.service.js b/server/api/services/wikipedia.service.js index 9c398cf4..8218cab7 100644 --- a/server/api/services/wikipedia.service.js +++ b/server/api/services/wikipedia.service.js @@ -17,7 +17,7 @@ const summaryUrlSnippet = "/w/api.php?format=json&action=query&prop=extracts&exi class WikipediaService { - getSummary(wikipediaUrl) { + getSummary(wikipediaUrl, dbg) { return new Promise((resolve, reject) =>{ // fetches summary text from Wikipedia // fetch all images in category @@ -31,7 +31,7 @@ class WikipediaService { resolve(summary); }) .catch(function (error) { - l.error(`Error fetching Wikipedia summary: ${error} (url: ${url})`); + l.error(`Error fetching Wikipedia summary: ${error} (url: ${url}) `+dbg); resolve('Error fetching Wikipedia summary'); }) });