From 7c0ee01c1d134cbee0a2c8243dd55e4eeaaa5f7c Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 30 May 2024 12:03:38 -0500 Subject: Move user creation from db resultset into static method Creation of a User object from the database resultset will mostly be the same. This commit moves the repetitive code into a static method that can be called wherever we need it. This improves maintainability, since we only ever need to do an update in one place now. --- scripts/migrate_existing_data.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/migrate_existing_data.py b/scripts/migrate_existing_data.py index ab3e739..1b44666 100644 --- a/scripts/migrate_existing_data.py +++ b/scripts/migrate_existing_data.py @@ -35,8 +35,7 @@ def sys_admins(conn: authdb.DbConnection) -> tuple[User, ...]: "INNER JOIN user_roles AS ur ON u.user_id=ur.user_id " "INNER JOIN roles AS r ON ur.role_id=r.role_id " "WHERE r.role_name='system-administrator'") - return tuple(User(UUID(row["user_id"]), row["email"], row["name"]) - for row in cursor.fetchall()) + return tuple(User.from_sqlite3_row(row) for row in cursor.fetchall()) return tuple() def choose_admin(enum_admins: dict[int, User]) -> int: -- cgit v1.2.3