query-6621b46d56a96ffd00fc93a19b7b271a

rq turtle/ttl

PropertiesPM20 folder ID (P4293)mapping relation type (P4390)number of works accessible online (P5592)

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
select (count(distinct ?wd) as ?total)
(?total - sum(?new) as ?preExistingItems)
(sum(?new) as ?itemsCreated)
(concat(str(round(sum(?new) / count(distinct ?id)*1000)/10), ' %') as ?percentageCreated)
where {
  # items with link to pm20 company folder
  ?statement ps:P4293 ?id .
  filter(strstarts(?id, 'co/'))
  ?wd p:P4293 ?statement .

  # don't take into account related matches (mapping relation type)
  optional {
      ?statement pq:P4390 ?relType .
  }
  filter(!bound(?relType) || ?relType!=wd:Q39894604)

  # count only folders with documents
  ?statement pq:P5592 ?docCount .

  # check if the item was created after start of the PM20 companies' linking phase
  # at 2021-04-26, first new item Q106647030
  bind(xsd:integer(strafter(str(?wd), concat(str(wd:), 'Q'))) as ?qidNum)
  bind(if(?qidNum >= 106647030, 1, 0) as ?new)
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?docCount") v2("?id") v10("?itemsCreated") v7("?new"):::projected v11("?percentageCreated") v9("?preExistingItems") v6("?qidNum") v1("?relType") v3("?statement") v8("?total"):::projected v4("?wd"):::projected f0[["(not bound(?relType) || ?relType != 'wd:Q39894604')"]] f0 --> v1 f1[["starts-with(?id,'co/')"]] f1 --> v2 v3 --"p:statement/P4293"--> v2 v4 --"p:P4293"--> v3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P4390".-> v1 end v3 --"p:qualifier/P5592"--> v5 bind2[/"http://www.w3.org/2001/XMLSchema#integer(substring-after(str(?wd),concat(str('wd:'),'Q')))"/] v4 --o bind2 bind2 --as--o v6 bind3[/"if(?qidNum >= '106647030^^xsd:integer','1^^xsd:integer','0^^xsd:integer')"/] v6 --o bind3 bind3 --as--o v7 bind9[/"count(?wd)"/] v4 --o bind9 bind9 --as--o v8 bind10[/"?total - "/] v8 --o bind10 null --o bind10 bind10 --as--o v9 bind11[/"sum(?new)"/] v7 --o bind11 bind11 --as--o v10 bind12[/"concat(str(numeric-round( / * '1000^^xsd:integer') / '10^^xsd:integer'),' %')"/] null --o bind12 null --o bind12 bind12 --as--o v11