vote: Properly take player and truth numbers into account
Fetch the amount of truths for the week and the player count to find the total possible votes. Use this to remove the hardocded value in the check. Update the check to fail if there was an error as well. Now that the truth count is calculated, send it to the javascript to build the graph labels automatically as well.
This commit is contained in:
parent
ba98c3be84
commit
07d8cf42d7
2 changed files with 26 additions and 10 deletions
|
@ -6,18 +6,20 @@ async function main() {
|
|||
return;
|
||||
}
|
||||
|
||||
const keys = ["Vérité 1", "Vérité 2", "Vérité 3", "Vérité 4", "Vérité 5", "Vérité 6", "Vérité 7"]
|
||||
let keys = []
|
||||
let datasets = []
|
||||
|
||||
try {
|
||||
const vote_data = (await vote_response.json()).votes;
|
||||
for (let player in vote_data) {
|
||||
const vote_data = (await vote_response.json());
|
||||
for (let player in vote_data.votes) {
|
||||
datasets.push({
|
||||
parsing: true,
|
||||
label: player,
|
||||
data: vote_data[player],
|
||||
data: vote_data.votes[player],
|
||||
})
|
||||
}
|
||||
for (let i = 1; i <= vote_data.truth_count; i++) {
|
||||
keys.push("Vérité " + i)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to parse vote data : \n\t" + error.message);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue