summaryrefslogtreecommitdiff
path: root/process-polls.py
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2024-09-17 07:42:43 -0400
committerBenji Dial <benji@benjidial.net>2024-09-17 07:42:43 -0400
commita1c85c3d28d9e7e7885d121d58470c0ba2e72eb9 (patch)
treeb12911dc054ba2e560245234345d54f7edc8bc62 /process-polls.py
parent890796c76d69ac377c3670e2ad305b24f53091f9 (diff)
downloadbracket-bot-main.tar.gz
have process-polls properly handle global_name = nullHEADmain
Diffstat (limited to 'process-polls.py')
-rw-r--r--process-polls.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/process-polls.py b/process-polls.py
index 63d3692..cd64764 100644
--- a/process-polls.py
+++ b/process-polls.py
@@ -67,8 +67,14 @@ for row in rows:
voters_1 = get_all_voters(s, row[4], row[5], answer_list_1[0]['answer_id'])
voters_2 = get_all_voters(s, row[4], row[5], answer_list_2[0]['answer_id'])
+ def user_to_params(user):
+ name = user['global_name']
+ if name is None:
+ name = user['username']
+ return (user['id'], name, user['avatar'], the_time)
+
cur.executemany('INSERT OR REPLACE INTO users VALUES(?, ?, ?, ?)',
- list(map(lambda x: (x['id'], x['global_name'], x['avatar'], the_time), voters_1 + voters_2)))
+ list(map(user_to_params, voters_1 + voters_2)))
cur.execute('''
UPDATE polls