User:TweetsFactsAndQueries/Queries/length of Wikipedia articles about fingers

Originally posted on Twitter.

# longest* Wikipedia articles about fingers
# *(measured in bytes of Wikitext, which is a terrible measure:
#   it counts categories, comments, and other kinds of metadata,
#   discounts anything contributed by templates except the template invocation,
#   and fails to account for different languages using more or less characters per word, or bytes per character)
SELECT ?finger ?fingerLabel ?endpoint ?title ?length ?article WITH {
  SELECT ?finger ?article ?endpoint ?title WHERE {
    ?finger wdt:P279 wd:Q620207.
    ?article schema:about ?finger;
             schema:isPartOf ?wiki;
             schema:name ?title.
    ?wiki wikibase:wikiGroup "wikipedia".
    # MINUS { ?wiki wikibase:wikiGroup "wikiquote". } # if you want to remove the previous line to check other projects, uncomment this one, Wikiquote is not allowed with MWAPI
    BIND(STRBEFORE(STRAFTER(STR(?wiki), "https://"), "/") AS ?endpoint)
  }
} AS %articles WHERE {
  hint:SubQuery hint:optimizer "None".
  INCLUDE %articles.
  SERVICE wikibase:mwapi {
    bd:serviceParam wikibase:api "Generator";
                    wikibase:endpoint ?endpoint;
                    mwapi:generator "allpages";
                    mwapi:gapfrom ?title;
                    mwapi:gaplimit 1;
                    wikibase:limit 1 .
    ?length_ wikibase:apiOutput "@length".
  }
  BIND(xsd:integer(?length_) AS ?length)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?length)
Try it!