query-157d9f9606c2e47d9150f68b786217f3

rq turtle/ttl

Newer items 16:43, 12 February 2022 (UTC)) talk (Lectrician1I want to find all items created within the last 30 days that have "genre: K-POP" and "instance of: extended play". : No such items are created in the last 30 days. I changed the limit to 40 days in the query below to prove it works:Lectrician1@ 17:33, 12 February 2022 (UTC)) talk (Lectrician1 (Q169930)extended play (Q213665)K-pop Dipsacus fullonum@ 17:31, 12 February 2022 (UTC)) talk (Dipsacus fullonumPlease give QID's for K-POP and extended play so we don't have to guess. Nothing obvious with these spellings seems to match. --

Use at

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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?created ?age ?title ?q_number
WHERE
{
  ?item p:P136/ps:P136 wd:Q213665 .
  ?item p:P31/ps:P31 wd:Q169930 .
  BIND (xsd:integer(SUBSTR(STR(?item), 33)) AS ?q_number)
  FILTER (?q_number > 110000000) # QQ110000000 is from 2021-12-08
  BIND (SUBSTR(STR(?item), 32) AS ?title)
  SERVICE wikibase:mwapi
  {
    bd:serviceParam wikibase:endpoint "www.wikidata.org" .
    bd:serviceParam wikibase:api "Generator" .
    bd:serviceParam mwapi:generator "allpages" .
    bd:serviceParam mwapi:gapfrom ?title .
    bd:serviceParam mwapi:gapto ?title .
    bd:serviceParam mwapi:prop "revisions" .
    bd:serviceParam mwapi:rvslots "main" .
    bd:serviceParam mwapi:rvprop "timestamp" .
    bd:serviceParam mwapi:rvdir "newer" .
    bd:serviceParam mwapi:rvlimit "1" .
    ?created wikibase:apiOutput "revisions/rev/@timestamp" .
    bd:serviceParam wikibase:limit "once" .
  }
  BIND (NOW() - xsd:dateTime(?created) AS ?age)
  FILTER (?age <= 40) # Created in the last 40 days
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
ORDER BY ?age

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?age"):::projected v5("?created"):::projected v3("?item"):::projected v4("?q_number"):::projected v4("?title"):::projected a1((" ")) a2((" ")) c5(["wd:Q213665"]):::iri c22(["main"]):::literal c10(["bd:serviceParam"]):::iri c16(["allpages"]):::literal c20(["revisions"]):::literal c24(["timestamp"]):::literal c12(["www.wikidata.org"]):::literal c8(["wd:Q169930"]):::iri c26(["newer"]):::literal c28(["1"]):::literal c32(["once"]):::literal c30(["revisions/rev/@timestamp"]):::literal c35(["#91;AUTO_LANGUAGE#93;,en"]):::literal c14(["Generator"]):::literal f0[["?age <= '40^^xsd:integer'"]] f0 --> v6 f1[["?q_number > '110000000^^xsd:integer'"]] f1 --> v4 v3 --"p:P136"--> a1 a1 --"p:statement/P136"--> c5 v3 --"p:P31"--> a2 a2 --"p:statement/P31"--> c8 bind2[/"http://www.w3.org/2001/XMLSchema#integer(substring(str(?item),'33^^xsd:integer'))"/] v3 --o bind2 bind2 --as--o v4 bind3[/"substring(str(?item),'32^^xsd:integer')"/] v3 --o bind3 bind3 --as--o v4 subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c10 --"mwapi:endpoint"--> c12 c10 --"mwapi:api"--> c14 c10 --"mwapi:generator"--> c16 c10 --"mwapi:gapfrom"--> v4 c10 --"mwapi:gapto"--> v4 c10 --"mwapi:prop"--> c20 c10 --"mwapi:rvslots"--> c22 c10 --"mwapi:rvprop"--> c24 c10 --"mwapi:rvdir"--> c26 c10 --"mwapi:rvlimit"--> c28 v5 --"mwapi:apiOutput"--> c30 c10 --"mwapi:limit"--> c32 end bind4[/"NOW() - http://www.w3.org/2001/XMLSchema#dateTime(?created)"/] v5 --o bind4 bind4 --as--o v6 subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c10 --"mwapi:language"--> c35 end