Wikidata:WikiProject Source MetaData/Wikidata lists/Usage of Template Scholia/Cross-wiki/Query

From Wikidata
Jump to navigation Jump to search

The following query uses these:

# Usage chart for Template:Scholia across several Wikipedias
# Note: this chart is based on https://www.wikidata.org/wiki/Wikidata:WikiProject_Source_MetaData/Wikidata_lists/Usage_of_Template_Scholia/Cross-wiki
# which is updated about once a day by ListeriaBot

#defaultView:LineChart
SELECT ?day ?count 
{
  BIND (CONCAT(" items") AS ?p)
  SERVICE wikibase:mwapi {
      bd:serviceParam wikibase:api "Generator" ; 
                      wikibase:endpoint "www.wikidata.org" ; 
                      mwapi:generator "allpages" ; 
                      mwapi:gapfrom "WikiProject_Source_MetaData/Wikidata_lists/Usage_of_Template_Scholia/Cross-wiki" ; 
                      mwapi:gapto "WikiProject_Source_MetaData/Wikidata_lists/Usage_of_Template_Scholia/Cross-wiki" ; 
                      mwapi:gapnamespace "4" ; 
                      mwapi:prop "revisions" ; 
                      mwapi:rvprop "content|timestamp" ; 
                      mwapi:rvlimit "7" ; 
                      mwapi:rvuser "ListeriaBot" .
      ?t1 wikibase:apiOutput "revisions/rev[1]/@timestamp" . ?r1 wikibase:apiOutput "revisions/rev[1]/text()" .
  }
  BIND (xsd:dateTime(?t1) AS ?day)
  FILTER (?day >= "2018-08-04T00:00:00Z"^^xsd:dateTime) .
  BIND (STRAFTER(?r1, "∑ ") AS ?BeforeString) 
  BIND (STRBEFORE(?BeforeString, ?p) AS ?AfterString) 
  BIND (IF(CONTAINS(?r1, ?p), xsd:integer(?AfterString), -1) AS ?count)
  FILTER (?count > 0 )
}