Key setup fucking works
This commit is contained in:
@@ -5,19 +5,21 @@ from database import SmartCursor
|
||||
class KeyTable:
|
||||
key: str
|
||||
game_table_id: number
|
||||
key_file: str
|
||||
created: bool
|
||||
updated: bool
|
||||
|
||||
def __init__(
|
||||
self, key: str, game_table_id: int, created: bool = True, updated: bool = True
|
||||
self, key: str, game_table_id: int, key_file: str, created: bool = True, updated: bool = True
|
||||
):
|
||||
self.key = key
|
||||
self.game_table_id = game_table_id
|
||||
self.key_file = key_file
|
||||
self.created = created
|
||||
self.updated = updated
|
||||
|
||||
def toJson(self):
|
||||
return {"key": self.key, "table_id": self.game_table_id}
|
||||
return {"key": self.key, "table_id": self.game_table_id, "key_file": self.key_file}
|
||||
|
||||
def reserve(self, game_table_id):
|
||||
self.game_table_id = game_table_id
|
||||
@@ -64,7 +66,7 @@ class KeyService:
|
||||
def get_key_for_table(self, game_table_id, cursor=None) -> KeyTable:
|
||||
with SmartCursor(cursor, self.connection) as smartCursor:
|
||||
smartCursor.execute(
|
||||
"""SELECT key, game_table_id
|
||||
"""SELECT key, game_table_id, key_file
|
||||
FROM game_keys
|
||||
WHERE game_table_id = ?""",
|
||||
(game_table_id,),
|
||||
@@ -74,21 +76,21 @@ class KeyService:
|
||||
if row == None:
|
||||
return None
|
||||
|
||||
return KeyTable(row[0], row[1])
|
||||
return KeyTable(row[0], row[1], row[2])
|
||||
|
||||
def get_reserved_keys(self, cursor=None) -> KeyTable:
|
||||
with SmartCursor(cursor, self.connection) as smartCursor:
|
||||
smartCurosr.execute("""SELECT key, game_table_id
|
||||
smartCurosr.execute("""SELECT key, game_table_id, key_file
|
||||
FROM game_keys
|
||||
WHERE game_table_id IS NOT NULL""")
|
||||
rows = smartCursor.fetchall()
|
||||
|
||||
return [KeyTable(row[0], row[1]) for row in rows]
|
||||
return [KeyTable(row[0], row[1, row[2]]) for row in rows]
|
||||
|
||||
def get_free_keys(self, cursor=None) -> KeyTable:
|
||||
with SmartCursor(cursor, self.connection) as smartCursor:
|
||||
smartCursor.execute("""SELECT key, game_table_id
|
||||
smartCursor.execute("""SELECT key, game_table_id, key_file
|
||||
FROM game_keys
|
||||
WHERE game_table_id IS NULL""")
|
||||
rows = smartCursor.fetchall()
|
||||
return [KeyTable(row[0], row[1]) for row in rows]
|
||||
return [KeyTable(row[0], row[1], row[2]) for row in rows]
|
||||
|
||||
Reference in New Issue
Block a user