fix: issues (1)
This commit is contained in:
@@ -123,7 +123,7 @@ class Database:
|
||||
try:
|
||||
if self.db_path is not None:
|
||||
self.run_migrations()
|
||||
except Exception as e:
|
||||
except (sql.Error, OSError, IOError) as e:
|
||||
log.error(f"Error while running migrations: {e}")
|
||||
|
||||
# --- Migration helpers integrated into Database ---
|
||||
@@ -212,9 +212,9 @@ class Database:
|
||||
).__str__()
|
||||
return result[0]
|
||||
|
||||
def getElsaMediaType(self, id):
|
||||
def getElsaMediaType(self, media_id):
|
||||
query = "SELECT type FROM elsa_media WHERE id=?"
|
||||
return self.query_db(query, (id,), one=True)[0]
|
||||
return self.query_db(query, (media_id,), one=True)[0]
|
||||
|
||||
def get_db_contents(self) -> Union[List[Tuple[Any]], None]:
|
||||
"""
|
||||
@@ -736,7 +736,7 @@ class Database:
|
||||
try:
|
||||
bloat.debug("Recreated file blob size: {} bytes", len(blob))
|
||||
bloat.debug("Recreated file blob (preview): {}", preview(blob, 2000))
|
||||
except Exception:
|
||||
except (TypeError, UnicodeDecodeError, ValueError):
|
||||
bloat.debug("Recreated file blob (preview): {}", preview(blob, 2000))
|
||||
tempdir = settings.database.temp.expanduser()
|
||||
if not tempdir.exists():
|
||||
@@ -990,16 +990,16 @@ class Database:
|
||||
person = Prof()
|
||||
return person.from_tuple(data)
|
||||
|
||||
def getProf(self, id) -> Prof:
|
||||
def getProf(self, prof_id) -> Prof:
|
||||
"""Get a professor based on the id
|
||||
|
||||
Args:
|
||||
id ([type]): the id of the professor
|
||||
prof_id ([type]): the id of the professor
|
||||
|
||||
Returns:
|
||||
Prof: a Prof object containing the data of the professor
|
||||
"""
|
||||
data = self.query_db("SELECT * FROM prof WHERE id=?", (id,), one=True)
|
||||
data = self.query_db("SELECT * FROM prof WHERE id=?", (prof_id,), one=True)
|
||||
return Prof().from_tuple(data)
|
||||
|
||||
def getProfs(self) -> list[Prof]:
|
||||
@@ -1278,17 +1278,17 @@ class Database:
|
||||
# print(apparat_nr, app_id)
|
||||
self.query_db("UPDATE media SET deleted=1 WHERE app_id=?", (app_id,))
|
||||
|
||||
def isEternal(self, id):
|
||||
def isEternal(self, apparat_id):
|
||||
"""check if the apparat is eternal (dauerapparat)
|
||||
|
||||
Args:
|
||||
id (int): the id of the apparat to be checked
|
||||
apparat_id (int): the id of the apparat to be checked
|
||||
|
||||
Returns:
|
||||
int: the state of the apparat
|
||||
"""
|
||||
return self.query_db(
|
||||
"SELECT dauer FROM semesterapparat WHERE appnr=?", (id,), one=True
|
||||
"SELECT dauer FROM semesterapparat WHERE appnr=?", (apparat_id,), one=True
|
||||
)
|
||||
|
||||
def getApparatName(self, app_id: Union[str, int], prof_id: Union[str, int]):
|
||||
|
||||
Reference in New Issue
Block a user