query-42e907b059bbe173308cea2f7b27505f

rq turtle/ttl

Vojtěch Dostálmw:Manual:$wgHashedUploadDirectory

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?username (COUNT(DISTINCT ?file) AS ?count)
WHERE
{

{
  SELECT ?file
  WHERE
  {

{
  SELECT ?item ?image ?filename ?contentUrl
  WHERE
  {
    SERVICE <https://query.wikidata.org/sparql>
    {
      ?item wdt:P31 wd:Q5153359 .
      ?item wdt:P18 ?image .
    }
    BIND (REPLACE(wikibase:decodeUri(SUBSTR(STR(?image), 52)), " ", "_") AS ?filename)
    BIND (MD5(?filename) AS ?MD5)
    BIND (URI(CONCAT("https://upload.wikimedia.org/wikipedia/commons/", SUBSTR(?MD5, 1, 1), "/", SUBSTR(?MD5, 1, 2), "/", ?filename)) As ?contentUrl)
  }
}    ?file schema:contentUrl ?contentUrl .
  }
}  ?file p:P170 / pq:P4174 ?username .
}
GROUP BY ?username

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?MD5") v5("?contentUrl") v8("?count") v6("?file"):::projected v3("?filename") v2("?image") v1("?item") v7("?username"):::projected a1((" ")) c3(["wd:Q5153359"]):::iri subgraph s1["https://query.wikidata.org/sparql"] style s1 stroke-width:4px; v1 --"p:direct/P31"--> c3 v1 --"p:direct/P18"--> v2 end bind0[/"replace(http://wikiba.se/ontology#decodeUri(substring(str(?image),'52^^xsd:integer')),' ','_')"/] v2 --o bind0 bind0 --as--o v3 bind1[/"MD5(?filename)"/] v3 --o bind1 bind1 --as--o v4 bind2[/"concat('https://upload.wikimedia.org/wikipedia/commons/',substring(?MD5,'1^^xsd:integer','1^^xsd:integer'),'/',substring(?MD5,'1^^xsd:integer','2^^xsd:integer'),'/',?filename)"/] v4 --o bind2 v3 --o bind2 bind2 --as--o v5 v6 --"schema:contentUrl"--> v5 v6 --"p:P170"--> a1 a1 --"p:qualifier/P4174"--> v7 bind4[/"count(?file)"/] v6 --o bind4 bind4 --as--o v8