query-fa640fae512c3283e0e71b8a6c178770

rq turtle/ttl

Recent events

Recent events

title: Recent events

select ?event ?eventLabel ?date { { SELECT distinct * { # find events ?event wdt:P31/wdt:P279* wd:Q1190554. # with a point in time or start date ?event wdt:P585|wdt:P580 ?date # not including « unknown values » FILTER(DATATYPE(?date) = xsd:dateTime). # not in the future, and not more than 31 days ago BIND(NOW() - ?date AS ?distance). # optimisation : all values are dates so we inform the query service of this fact hint:Prior hint:rangeSafe true FILTER(0 <= ?distance && ?distance < 31). } # limit to 100 results so we don't timeout LIMIT 100 } # getting the event label in an outer query, to speed up and not getting the label for filtered candidates SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } order by desc(?date) # sorting result by more recent one first

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Recent events
#Recent events
#title: Recent events

select ?event ?eventLabel ?date {
  {
    SELECT distinct * 
    {
      # find events
      ?event wdt:P31/wdt:P279* wd:Q1190554.
      # with a point in time or start date
      ?event wdt:P585|wdt:P580 ?date 
      # not including « unknown values » 
      FILTER(DATATYPE(?date) = xsd:dateTime). 
      # not in the future, and not more than 31 days ago
      BIND(NOW() - ?date AS ?distance). 
      # optimisation : all values are dates so we inform the query service of this fact

    }
  # limit to 100 results so we don't timeout
  LIMIT 100
  }
  # getting the event label in an outer query, to speed up and not getting the label for filtered candidates
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by desc(?date) # sorting result by more recent one first

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?date"):::projected v3("?distance") v2("?event"):::projected a1((" ")) c8(["bd:serviceParam"]):::iri c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal c4(["wd:Q1190554"]):::iri f0[["?date = 'xsd:dateTime'"]] f0 --> v1 v2 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c4 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P580"--> v1 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P585"--> v1 end union0r <== or ==> union0l end bind1[/"NOW() - ?date"/] v1 --o bind1 bind1 --as--o v3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end