Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/369630 )

Change subject: Add support for SPARQL2 template in template data
......................................................................

Add support for SPARQL2 template in template data

With recent changes to the SPARQL2 template, for some reason it looks
just like the SPARQL template in the mw-data, so we can parse it with
the same code as the SPARQL template.

The old code for parsing the SPARQL2 template (using data.body.extsrc)
is removed, because without removing it some (but not all) SPARQL2 query
examples are loaded twice for some reason.

Bug: T172259
Change-Id: I061d376da3d163b34f89470bebced87490eec765
---
M wikibase/queryService/api/QuerySamples.js
1 file changed, 9 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui 
refs/changes/30/369630/1

diff --git a/wikibase/queryService/api/QuerySamples.js 
b/wikibase/queryService/api/QuerySamples.js
index 8e62ed6..54ee7d8 100644
--- a/wikibase/queryService/api/QuerySamples.js
+++ b/wikibase/queryService/api/QuerySamples.js
@@ -120,14 +120,17 @@
                        }
 
                        var data = JSON.parse( dataMW ),
+                               templateHref,
                                query;
 
-                       if ( data.parts && data.parts[0].template && 
data.parts[0].template.target.href === './Template:SPARQL' ) {
-                               // SPARQL template
-                               query = data.parts[0].template.params.query.wt;
-                       } else if ( data.body ) {
-                               // SPARQL2 template
-                               query = data.body.extsrc;
+                       if ( data.parts && data.parts[0].template ) {
+                               templateHref = 
data.parts[0].template.target.href;
+                               if ( templateHref === './Template:SPARQL' || 
templateHref === './Template:SPARQL2' ) {
+                                       // SPARQL/SPARQL2 template
+                                       query = 
data.parts[0].template.params.query.wt;
+                               } else {
+                                       return null;
+                               }
                        } else {
                                return null;
                        }

-- 
To view, visit https://gerrit.wikimedia.org/r/369630
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I061d376da3d163b34f89470bebced87490eec765
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to