query-e58884bc94ebaffc2076934ce8e88286
Totals version of above
Use at
- https://query.wikidata.org/sparql
PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item1 (SUM(?size) as ?total_bytes) (COUNT(?sitelink) AS ?sites)
WHERE {
VALUES ?item1 {wd:Q9438}
?sitelink schema:about ?item1 # get Wikimedia pages
FILTER(CONTAINS(str(?sitelink), ".wikipedia.org/")) # only Wikipedia articles
?sitelink schema:name ?title ; schema:isPartOf ?site.
BIND(REPLACE(SUBSTR(STR(?site), 9), '/', '') AS ?endpoint)
OPTIONAL{
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:api "Generator" ;
wikibase:endpoint ?endpoint ;
mwapi:generator "allpages" ;
mwapi:gapfrom ?title ;
mwapi:gapto ?title ;
mwapi:prop "revisions" ;
mwapi:rvprop "size" .
?bytes wikibase:apiOutput "revisions/rev/@size" .
}
BIND (xsd:integer(?bytes) AS ?size)
}
} GROUP BY ?item1
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?bytes")
v5("?endpoint")
v2("?item1"):::projected
v4("?site")
v1("?sitelink"):::projected
v9("?sites")
v7("?size"):::projected
v3("?title")
v8("?total_bytes")
c19(["revisions/rev/@size"]):::literal
c6(["bd:serviceParam"]):::iri
c17(["size"]):::literal
c11(["allpages"]):::literal
c15(["revisions"]):::literal
c8(["Generator"]):::literal
f0[["contains(str(?sitelink),'.wikipedia.org/')"]]
f0 --> v1
bind1[/VALUES ?item1/]
bind1-->v2
bind10(["wd:Q9438"])
bind10 --> bind1
v1 --"schema:about"--> v2
v1 --"schema:name"--> v3
v1 --"schema:isPartOf"--> v4
bind2[/"replace(substring(str(?site),'9^^xsd:integer'),'/','')"/]
v4 --o bind2
bind2 --as--o v5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
subgraph s1["http://wikiba.se/ontology#mwapi"]
style s1 stroke-width:4px;
c6 -."mwapi:api".-> c8
c6 --"mwapi:endpoint"--> v5
c6 --"mwapi:generator"--> c11
c6 --"mwapi:gapfrom"--> v3
c6 --"mwapi:gapto"--> v3
c6 --"mwapi:prop"--> c15
c6 --"mwapi:rvprop"--> c17
v6 --"mwapi:apiOutput"--> c19
end
bind3[/"http://www.w3.org/2001/XMLSchema#integer(?bytes)"/]
v6 --o bind3
bind3 --as--o v7
end
bind6[/"sum(?size)"/]
v7 --o bind6
bind6 --as--o v8
bind7[/"count(?sitelink)"/]
v1 --o bind7
bind7 --as--o v9