mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Use get_first() in models.py
This commit is contained in:
parent
5541435a30
commit
5b6f0d76f2
1 changed files with 5 additions and 9 deletions
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue