aboutsummaryrefslogtreecommitdiff
path: root/api/randid.py
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-04-16 16:57:26 +0200
committerlonkaars <l.leblansch@gmail.com>2021-04-16 16:57:26 +0200
commit07c2b124e4348b15f1e5ec18c6cdfd77248c6bc8 (patch)
treee4a29123d3ebedc1d25500390c904c66b3b02489 /api/randid.py
parentaa2c999702dadba2afbcf2be9f597f890aafcc87 (diff)
spaces > tabs in python :(
Diffstat (limited to 'api/randid.py')
-rw-r--r--api/randid.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/api/randid.py b/api/randid.py
index 6c1ca9d..e0baf43 100644
--- a/api/randid.py
+++ b/api/randid.py
@@ -6,13 +6,13 @@ tables = {"users": "user_id", "games": "game_id"}
# generate a new uuid and check for collisions (unlikely but still)
def new_uuid(table_name):
- temp_uuid = str(uuid.uuid4())
- column_name = tables[table_name]
- # check if id is already taken
- if cursor.execute(
- f"select {column_name} from {table_name} where {column_name} = ?",
- [temp_uuid]
- ).fetchone():
- return new_uuid(table_name)
- else:
- return temp_uuid
+ temp_uuid = str(uuid.uuid4())
+ column_name = tables[table_name]
+ # check if id is already taken
+ if cursor.execute(
+ f"select {column_name} from {table_name} where {column_name} = ?",
+ [temp_uuid]
+ ).fetchone():
+ return new_uuid(table_name)
+ else:
+ return temp_uuid