Class: WikidataPositionHistory::SPARQL::ConstituencyMandatesQuery
- Inherits:
-
ItemQuery
- Object
- ItemQuery
- WikidataPositionHistory::SPARQL::ConstituencyMandatesQuery
- Defined in:
- lib/sparql/mandates_query.rb
Overview
SPARQL for fetching all mandates of a single-member district
Instance Method Summary collapse
Methods inherited from ItemQuery
#initialize, #results_as, #wdqs_url
Constructor Details
This class inherits a constructor from WikidataPositionHistory::SPARQL::ItemQuery
Instance Method Details
#raw_sparql ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/sparql/mandates_query.rb', line 31 def raw_sparql " # constituency-mandates\n\n SELECT DISTINCT ?ordinal ?item ?start_date ?start_precision ?end_date ?end_precision ?party ?prev ?next ?term\n WHERE {\n ?item wdt:P31 wd:Q5 ; p:P39 ?posn .\n ?posn pq:P768 wd:%s .\n FILTER NOT EXISTS { ?posn wikibase:rank wikibase:DeprecatedRank }\n\n OPTIONAL { ?posn pqv:P580 [ wikibase:timeValue ?start_date; wikibase:timePrecision ?start_precision ] }\n OPTIONAL { ?posn pqv:P582 [ wikibase:timeValue ?end_date; wikibase:timePrecision ?end_precision ] }\n OPTIONAL { ?posn pq:P1365 ?prev }\n OPTIONAL { ?posn pq:P1366 ?next }\n OPTIONAL { ?posn pq:P4100 ?party }\n OPTIONAL {\n ?posn pq:P2937 ?term .\n OPTIONAL { ?term p:P31/pq:P1545 ?ordinal }\n }\n }\n ORDER BY DESC(?start_date) ?item\n SPARQL\nend\n" |