Make each property OPTIONAL
authorDan Scott <dan@coffeecode.net>
Sat, 12 Aug 2017 19:27:17 +0000 (15:27 -0400)
committerDan Scott <dan@coffeecode.net>
Sat, 12 Aug 2017 19:27:17 +0000 (15:27 -0400)
By making the entire set of properties in a single OPTIONAL clause,
we were only getting properties when all of them were present.

Signed-off-by: Dan Scott <dan@coffeecode.net>
Open-ILS/web/js/ui/default/opac/wikidata_music_card.js

index 69f4398..a87e60d 100644 (file)
   function findPerformer(icon_node, entity_name) {
     var url = 'https://query.wikidata.org/sparql';
     var query = 'SELECT DISTINCT ?item ?itemLabel ?itemDescription ?image ?birthPlace ?birthPlaceLabel ' +
-        '  ?website ?musicbrainz ?songKick ?twitter ?facebook WHERE {' +
+        '?website ?musicbrainz ?songKick ?twitter ?facebook ' +
+        'WHERE { ' +
         '?item rdfs:label|skos:altLabel|wdt:P1449 "' + entity_name + '"@en . ' +
         '{ ?item wdt:P31 wd:Q215380 . } ' + // band
         'UNION ' +
         '{ ?item wdt:P31 wd:Q5741069 . } ' + // rock band
         'UNION ' +
         '{ ?item wdt:P106/wdt:P279* wd:Q639669 . } ' +
-        'OPTIONAL { ?item wdt:P3478 ?songKick . ' +
-        '  ?item wdt:P19 ?birthPlace . ' +
-        '  ?item wdt:P856 ?website . ' +
-        '  ?item wdt:P434 ?musicbrainz . ' +
-        '  ?item wdt:P2002 ?twitter . ' +
-        '  ?item wdt:P2013 ?facebook . ' +
-        '  ?item wdt:P18 ?image } . ' +
+        'OPTIONAL { ?item wdt:P3478 ?songKick . ' +
+        'OPTIONAL { ?item wdt:P19 ?birthPlace } . ' +
+        'OPTIONAL { ?item wdt:P856 ?website } . ' +
+        'OPTIONAL { ?item wdt:P434 ?musicbrainz } . ' +
+        'OPTIONAL { ?item wdt:P2002 ?twitter } . ' +
+        'OPTIONAL { ?item wdt:P2013 ?facebook } . ' +
+        'OPTIONAL { ?item wdt:P18 ?image } . ' +
         'SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } ' +
     '} ' +
     'LIMIT 10';