Compare commits

..

No commits in common. "fuck-you-tom" and "main" have entirely different histories.

3 changed files with 16 additions and 46 deletions

View File

@ -6,11 +6,7 @@ def main():
db = DatabaseService("config.toml")
db.init_db()
user_id = input("Einzelticket ID:")
if user_id == "":
badges = db.get_user_badges()
else:
badges = db.get_user_badges(int(user_id.strip()))
badges = db.get_user_badges()
badge_generator = BadgeGeneratorService("config.toml")

View File

@ -1,13 +0,0 @@
import os
from subprocess import check_output, DEVNULL
from from_root import from_root
for file in os.listdir(from_root("output_badges")):
if file.endswith(".pdf"):
outfile_name = file.split(".pdf")[0]
outfile_name += "-print.pdf"
check_output(
["pdfjam", file, "--nup", "1x2", "--paper", "a4paper", "--noautoscale", "true", "--outfile", outfile_name],
stderr=DEVNULL
)

View File

@ -24,31 +24,18 @@ class DatabaseService:
cursorclass=pymysql.cursors.DictCursor)
logger.info("Connected to database.")
def get_user_badges(self, user_id: Optional[int] = None) -> List[Dict]:
if user_id is None:
with self._conn.cursor() as cursor:
cursor.execute(
"""SELECT u.user_id, u.user_name, s.seat_id, upp.picture, tic.ticket_id
FROM users AS u
LEFT JOIN seats AS s
ON u.user_id = s.`user`
LEFT JOIN user_profile_picture AS upp
ON u.user_id = upp.user_id
INNER JOIN tickets AS tic
ON u.user_id = tic.user;"""
)
user_badges = cursor.fetchall()
else:
with self._conn.cursor() as cursor:
cursor.execute(
"""SELECT u.user_id, u.user_name, s.seat_id, upp.picture
FROM users AS u
LEFT JOIN seats AS s
ON u.user_id = s.`user`
LEFT JOIN user_profile_picture AS upp
ON u.user_id = upp.user_id
WHERE u.user_id = %s;""", (user_id,)
)
user_badges = cursor.fetchall()
logger.info(f"Got {len(user_badges)} user badges from database.")
return user_badges
def get_user_badges(self) -> List[Dict]:
with self._conn.cursor() as cursor:
cursor.execute(
"""SELECT u.user_id, u.user_name, s.seat_id, upp.picture, tic.ticket_id
FROM users AS u
LEFT JOIN seats AS s
ON u.user_id = s.`user`
LEFT JOIN user_profile_picture AS upp
ON u.user_id = upp.user_id
INNER JOIN tickets AS tic
ON u.user_id = tic.user;"""
)
user_badges = cursor.fetchall()
logger.info(f"Got {len(user_badges)} user badges from database.")
return user_badges