From 84f8388e398ef8d9d2ff769d703747ecc17ff0f5 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Sun, 25 Feb 2024 21:52:04 +1100 Subject: [PATCH] fix: Make sure to use ints --- render.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/render.py b/render.py index b29164c..3ca801e 100644 --- a/render.py +++ b/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())