session_name_votes = Promise.all(plenary_meetings_unfolded.map(meeting => {
const topics = meeting.topics;
const array = [];
for(const key in topics['TopicType.NAME_VOTE']) {
const nv = topics['TopicType.NAME_VOTE'][key];
if(nv.legislation.length === 0) continue;
const legislations = nv.legislation.map(url => legislations_unfolded[+url.match(/legislation\/(\d+)\.json$/)[1]]);
let contains = false;
for(const legislation of legislations) {
for(const author of legislation.authors) {
if(member_urls_of_this_party.has(author)) {
contains = true;
break;
}
}
if(contains) break;
}
if(!contains) continue;
nv.yes = nv.votes[0]?.voters.yes.length;
nv.no = nv.votes[0]?.voters.no.length;
nv.abstention = nv.votes[0]?.voters.abstention.length;
nv.meeting = parseInt(meeting.id);
nv.yesPerc = nv.yes / (nv.yes + nv.no + nv.abstention);
if(isNaN(nv.yesPerc)){
nv.yesPerc = 0.0
}
nv.noPerc = nv.no / (nv.yes + nv.no + nv.abstention)
if(isNaN(nv.noPerc)){
nv.noPerc = 0.0
}
array.push(nv);
}
return array;
}))