Skip to content

Commit

Permalink
https://github.com/water-fountains/datablue/issues/39
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf Hauser committed Dec 15, 2019
1 parent ebe82ac commit 0d82ef4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
10 changes: 5 additions & 5 deletions server/api/services/processing.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand All @@ -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 = [];
Expand All @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions server/api/services/wikidata.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand Down
2 changes: 2 additions & 0 deletions server/api/services/wikimedia.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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+'"');
}
});

Expand Down
4 changes: 2 additions & 2 deletions server/api/services/wikipedia.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');
})
});
Expand Down

0 comments on commit 0d82ef4

Please sign in to comment.