-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd_P39.js
28 lines (25 loc) · 1.05 KB
/
add_P39.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module.exports = (id, startdate, enddate, replaces, replacedby, ordinal, cabinet) => {
const qualifiers = { }
// Seems like there should be a better way of filtering these...
if (startdate && startdate != "''") qualifiers['P580'] = startdate
if (enddate && enddate != "''") qualifiers['P582'] = enddate
if (replaces && replaces != "''") qualifiers['P1365'] = replaces
if (replacedby && replacedby != "''") qualifiers['P1366'] = replacedby
if (ordinal && ordinal != "''") qualifiers['P1545'] = ordinal
if (cabinet && cabinet != "''") qualifiers['P5054'] = cabinet
if (startdate && enddate && startdate != "''" && enddate != "''" &&
(startdate > enddate)) throw new Error(`Invalid dates: ${startdate} / ${enddate}`)
return {
id,
claims: {
P39: {
value: 'Q27961995',
qualifiers: qualifiers,
references: {
P143: 'Q328', // English Wikipedia
P4656: 'https://en.wikipedia.org/wiki/Shadow_Secretary_of_State_for_Exiting_the_European_Union'
},
}
}
}
}