diff --git a/advlabdb/models.py b/advlabdb/models.py index 3c5b877..35eb747 100644 --- a/advlabdb/models.py +++ b/advlabdb/models.py @@ -16,6 +16,7 @@ from sqlalchemy import select from . import db from .configUtils import getConfig from .exceptions import DataBaseException +from .model_independent_funs import get_first MIN_MARK = 0 MAX_MARK = 15 @@ -171,15 +172,10 @@ class Group(db.Model): semester = part_students[0].part.semester program = part_students[0].part.program - highestGroupNumber = ( - db.session.execute( - select(Group.number) - .where(Group.semester == semester, Group.program == program) - .order_by(Group.number.desc()) - .limit(1) - ) - .scalars() - .first() + highestGroupNumber = get_first( + select(Group.number) + .where(Group.semester == semester, Group.program == program) + .order_by(Group.number.desc()) ) if highestGroupNumber is not None: