-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexisting-p39s.js
20 lines (18 loc) · 975 Bytes
/
existing-p39s.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// List of P39 data for this position. Fetch with:
// wd sparql office-holders.sparql Q<office id> | tee wikidata.json
module.exports = office => `
SELECT ?statement ?item ?itemLabel ?ordinal ?replaces ?replacesLabel ?replacedBy ?replacedByLabel
?start ?startPrecision ?end ?endPrecision ?cabinet WHERE {
?item wdt:P31 wd:Q5; p:P39 ?statement.
?statement ps:P39 wd:${office}.
MINUS { ?statement wikibase:rank wikibase:DeprecatedRank. }
OPTIONAL { ?statement pqv:P580 [ wikibase:timeValue ?start; wikibase:timePrecision ?startPrecision ] }
OPTIONAL { ?statement pqv:P582 [ wikibase:timeValue ?end; wikibase:timePrecision ?endPrecision ] }
OPTIONAL { ?statement pq:P1365 ?replaces }
OPTIONAL { ?statement pq:P1366 ?replacedBy }
OPTIONAL { ?statement pq:P1545 ?ordinal }
OPTIONAL { ?statement pq:P5054 ?cabinet }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?start
`