From fce8aac001762cf5004a46b9cdcc4005549732f8 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Wed, 2 Nov 2022 08:59:25 +0100 Subject: [PATCH] Import creator users as well --- lib/user.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/user.py b/lib/user.py index 688d6df..813d218 100644 --- a/lib/user.py +++ b/lib/user.py @@ -52,13 +52,24 @@ class User: @staticmethod def missing_users(db): + missing_users = set() with db.cursor() as cur: cur.execute( - """SELECT DISTINCT revisions.userid - FROM revisions LEFT JOIN users ON revisions.userid = users.userid + """SELECT DISTINCT revisions.userid + FROM revisions LEFT JOIN users ON revisions.userid = users.userid WHERE users.userid IS NULL AND revisions.userid NOT IN {}""".format( FAKE_ACCOUNTS ) ) - missing_users = [row[0] for row in cur.fetchall()] - return missing_users + for row in cur.fetchall(): + missing_users.add(row[0]) + cur.execute( + """SELECT DISTINCT requests.creator + FROM requests LEFT JOIN users ON requests.creator=users.userid + WHERE users.userid IS NULL AND requests.creator NOT IN {}""".format( + FAKE_ACCOUNTS + ) + ) + for row in cur.fetchall(): + missing_users.add(row[0]) + return sorted(missing_users)