@@ -806,39 +806,52 @@ secondayFilterValues = Vue.component('secondary-filters', {
806806" SERVICE wikibase:label {\n" +
807807" bd:serviceParam wikibase:language \"" + lang + "\".\n" +
808808" ?value rdfs:label ?valueLabel\n" +
809- " }\n" ;
809+ " }\n" +
810+ "}\n" ;
810811parentFilterString = "SERVICE <" + centralSPARQLService + "> {\n" +
811812parentFilterString +
812813"\n}\n" ;
813814} else {
814815labelClause = " SERVICE wikibase:label { bd:serviceParam wikibase:language \"" + lang + "\". }\n" ;
815816}
816817
817- var sparqlQuery = "SELECT ?value ?valueLabel ?count\n" +
818- "WITH {\n" +
819- "SELECT ?temp (count(?temp) as ?tempCount) WHERE {\n" +
820- vm . classSelector +
821- "?item wdt:" + vm . currentFilter . value + " ?temp.\n" +
818+ var sparqlQuery = "SELECT ?value ?valueLabel ?count\n" ;
819+
820+ if ( centralSPARQLService ) {
821+ sparqlQuery += "WITH {\n" +
822+ "SELECT ?temp (count(?temp) as ?tempCount) WHERE {\n" ;
823+ } else {
824+ sparqlQuery += "WHERE {\n" +
825+ "{\n" +
826+ "SELECT ?value (COUNT(?value) AS ?count) WHERE {\n" ;
827+ }
828+
829+ sparqlQuery += vm . classSelector +
830+ "{\n?item wdt:" + vm . currentFilter . value + " ?temp .\n" +
831+ "?temp wdt:" + vm . secondaryFilter . value + " ?value\n}\n" +
822832filterString +
823833filterRanges +
824834filterQuantities +
825- noValueString +
826- "\n} GROUP BY ?temp\n" +
827- "} AS %local\n" +
828- "WHERE {\n" +
829- "{\n" +
830- "SELECT ?value (sum(?tempCount) as ?count) WHERE {\n" +
831- "INCLUDE %local\n" +
832- parentFilterString +
835+ noValueString ;
836+
837+ if ( centralSPARQLService ) {
838+ sparqlQuery += "\n} GROUP BY ?temp\n" +
839+ "} AS %local\n" +
840+ "WHERE {\n" +
841+ "{\n" +
842+ "SELECT ?value (sum(?tempCount) as ?count) WHERE {\n" +
843+ "INCLUDE %local\n" ;
844+ }
845+
846+ sparqlQuery += parentFilterString +
833847"}\n" +
834848"GROUP BY ?value\n" +
835849"ORDER BY DESC (?count)\n" +
836850"LIMIT 1000\n" +
837851"}\n" +
838852labelClause +
839853"}\n" +
840- "}\n" +
841- "ORDER BY DESC (?count)\n" ;
854+ "ORDER BY DESC (?count)" ;
842855vm . query = queryServiceWebsiteURL + encodeURIComponent ( sparqlQuery ) ;
843856var fullUrl = sparqlEndpoint + encodeURIComponent ( sparqlQuery ) ;
844857axios . get ( fullUrl )