fix: Make sure to use ints
All checks were successful
Build Docker / Build Image (push) Successful in 21s

This commit is contained in:
Nathan Woodburn 2024-02-25 21:52:04 +11:00
parent b3d9e66916
commit 84f8388e39
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -9,21 +9,23 @@ def votes():
print(votes)
options = {}
for vote in votes:
# Check if message is json
if 'votes' not in vote:
continue
weight = int(vote["votes"])
if vote["message"].startswith("{"):
message = json.loads(vote["message"])
for key in message:
if key in options:
options[key] += (int(message[key]) * int(vote["votes"]))
options[key] += (int(message[key]) * weight)
else:
options[key] = (int(message[key]) * int(vote["votes"]))
options[key] = (int(message[key]) * weight)
continue
if vote["message"] in options:
options[vote["message"]] += vote["votes"]
options[vote["message"]] += weight
else:
options[vote["message"]] = vote["votes"]
options[vote["message"]] = weight
labels = list(options.keys())