1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-20 23:41:20 +00:00

Use get_first() in models.py

This commit is contained in:
Mo 2022-05-16 22:23:15 +02:00
parent 5541435a30
commit 5b6f0d76f2

View file

@ -16,6 +16,7 @@ from sqlalchemy import select
from . import db from . import db
from .configUtils import getConfig from .configUtils import getConfig
from .exceptions import DataBaseException from .exceptions import DataBaseException
from .model_independent_funs import get_first
MIN_MARK = 0 MIN_MARK = 0
MAX_MARK = 15 MAX_MARK = 15
@ -171,15 +172,10 @@ class Group(db.Model):
semester = part_students[0].part.semester semester = part_students[0].part.semester
program = part_students[0].part.program program = part_students[0].part.program
highestGroupNumber = ( highestGroupNumber = get_first(
db.session.execute(
select(Group.number) select(Group.number)
.where(Group.semester == semester, Group.program == program) .where(Group.semester == semester, Group.program == program)
.order_by(Group.number.desc()) .order_by(Group.number.desc())
.limit(1)
)
.scalars()
.first()
) )
if highestGroupNumber is not None: if highestGroupNumber is not None: