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)
|
print(votes)
|
||||||
|
|
||||||
options = {}
|
options = {}
|
||||||
|
|
||||||
for vote in votes:
|
for vote in votes:
|
||||||
# Check if message is json
|
# Check if message is json
|
||||||
|
if 'votes' not in vote:
|
||||||
|
continue
|
||||||
|
weight = int(vote["votes"])
|
||||||
if vote["message"].startswith("{"):
|
if vote["message"].startswith("{"):
|
||||||
message = json.loads(vote["message"])
|
message = json.loads(vote["message"])
|
||||||
for key in message:
|
for key in message:
|
||||||
if key in options:
|
if key in options:
|
||||||
options[key] += (int(message[key]) * int(vote["votes"]))
|
options[key] += (int(message[key]) * weight)
|
||||||
else:
|
else:
|
||||||
options[key] = (int(message[key]) * int(vote["votes"]))
|
options[key] = (int(message[key]) * weight)
|
||||||
continue
|
continue
|
||||||
if vote["message"] in options:
|
if vote["message"] in options:
|
||||||
options[vote["message"]] += vote["votes"]
|
options[vote["message"]] += weight
|
||||||
else:
|
else:
|
||||||
options[vote["message"]] = vote["votes"]
|
options[vote["message"]] = weight
|
||||||
|
|
||||||
|
|
||||||
labels = list(options.keys())
|
labels = list(options.keys())
|
||||||
|
Loading…
Reference in New Issue
Block a user