Class: WikidataPositionHistory::SPARQL::MandatesQuery

Inherits:
ItemQuery
  • Object
show all
Defined in:
lib/sparql/mandates_query.rb

Overview

SPARQL for fetching all officeholdings of a position

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_sparqlObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sparql/mandates_query.rb', line 7

def raw_sparql
  "    # position-mandates\n\n    SELECT DISTINCT ?ordinal ?item ?start_date ?start_precision ?end_date ?end_precision ?prev ?next ?nature\n    WHERE {\n      ?item wdt:P31 wd:Q5 ; p:P39 ?posn .\n      ?posn ps:P39 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|pq:P155 ?prev }\n      OPTIONAL { ?posn pq:P1366|pq:P156 ?next }\n      OPTIONAL { ?posn pq:P1545 ?ordinal }\n      OPTIONAL { ?posn pq:P5102 ?nature }\n    }\n    ORDER BY DESC(?start_date) ?item\n  SPARQL\nend\n"