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 .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: