WDscholia / scholia

Wikidata-based scholarly profiles
https://scholia.toolforge.org
Other
225 stars 81 forks source link

Make page production query faster #2545

Closed fnielsen closed 1 month ago

fnielsen commented 1 month ago

What query is this about https://scholia.toolforge.org/organization/Q24283660#page-production

What change do you propose, and why?

# tool: scholia
#defaultView:BarChart

PREFIX target: <http://www.wikidata.org/entity/Q24283660>

# Pages per year bar chart of an organization
SELECT
  ?year
  (SUM(?pages_per_author) AS ?number_of_pages)
  ?researcher ?researcherLabel
WITH {
  SELECT 
    DISTINCT ?researcher
  WHERE {
    ?researcher wdt:P108 | wdt:P463 | (wdt:P1416 / wdt:P361*) target: .
  }
} AS %researchers
WITH {
    SELECT
      ?researcher ?work ?year
      (SAMPLE(?pages) / COUNT(?researcher_of_paper) AS ?pages_per_author)
    WHERE {
      INCLUDE %researchers

      ?work (wdt:P50 | wdt:P2093) ?researcher_of_paper .

      # Disabled to only look on scholarly articles
      # ?work wdt:P31 wd:Q13442814 .

      ?work wdt:P50 ?researcher ;
            wdt:P1104 ?pages ;
            wdt:P577 ?date . 
      BIND(STR(YEAR(?date)) AS ?year) 
    } 
    GROUP BY ?work ?researcher ?year
} AS %results
WHERE {
  INCLUDE %results
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}
GROUP BY ?year ?researcher ?researcherLabel
ORDER BY ?year

Any other considerations?