fix: Make sure to use ints
All checks were successful
Build Docker / Build Image (push) Successful in 21s
All checks were successful
Build Docker / Build Image (push) Successful in 21s
This commit is contained in:
parent
b3d9e66916
commit
84f8388e39
12
render.py
12
render.py
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user