mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Replace count()
This commit is contained in:
parent
eba6122aef
commit
48c6f4a744
1 changed files with 23 additions and 22 deletions
|
@ -5,9 +5,10 @@ from flask_admin.helpers import get_form_data
|
||||||
from flask_admin.model.helpers import get_mdict_item_or_list
|
from flask_admin.model.helpers import get_mdict_item_or_list
|
||||||
from flask_admin.model.template import EndpointLinkRowAction
|
from flask_admin.model.template import EndpointLinkRowAction
|
||||||
from flask_security import current_user
|
from flask_security import current_user
|
||||||
from sqlalchemy import and_
|
from sqlalchemy import and_, select
|
||||||
|
|
||||||
from .dependent_funs import reportBadAttempt, userActiveSemester
|
from . import db
|
||||||
|
from .dependent_funs import get_count, reportBadAttempt, userActiveSemester
|
||||||
from .exceptions import DataBaseException, ModelViewException
|
from .exceptions import DataBaseException, ModelViewException
|
||||||
from .models import (
|
from .models import (
|
||||||
Assistant,
|
Assistant,
|
||||||
|
@ -39,15 +40,17 @@ class SecureAdminIndexView(CustomIndexView):
|
||||||
|
|
||||||
@expose("/")
|
@expose("/")
|
||||||
def index(self):
|
def index(self):
|
||||||
active_semester_experiment_marks_query = ExperimentMark.query.filter(
|
active_semester_experiment_mark_ids_stmt = (
|
||||||
ExperimentMark.part_student.has(PartStudent.part.has(Part.semester == userActiveSemester()))
|
select(ExperimentMark.final_experiment_mark)
|
||||||
|
.join(PartStudent)
|
||||||
|
.join(Part)
|
||||||
|
.where(Part.semester == userActiveSemester())
|
||||||
)
|
)
|
||||||
|
number_of_all_experiment_marks = get_count(active_semester_experiment_mark_ids_stmt)
|
||||||
|
|
||||||
number_of_all_experiment_marks = active_semester_experiment_marks_query.count()
|
number_of_missing_final_experiment_marks = get_count(
|
||||||
|
active_semester_experiment_mark_ids_stmt.where(ExperimentMark.final_experiment_mark == None)
|
||||||
number_of_missing_final_experiment_marks = active_semester_experiment_marks_query.filter(
|
)
|
||||||
ExperimentMark.final_experiment_mark == None
|
|
||||||
).count()
|
|
||||||
|
|
||||||
return self.render(
|
return self.render(
|
||||||
"admin_index.html",
|
"admin_index.html",
|
||||||
|
@ -62,22 +65,20 @@ class SecureAssistantIndexView(CustomIndexView):
|
||||||
|
|
||||||
@expose("/")
|
@expose("/")
|
||||||
def index(self):
|
def index(self):
|
||||||
active_semester_experiment_marks_query = ExperimentMark.query.filter(
|
active_semester_experiment_mark_ids_stmt = (
|
||||||
ExperimentMark.group_experiment.has(
|
select(ExperimentMark.final_experiment_mark)
|
||||||
GroupExperiment.semester_experiment.has(
|
.join(GroupExperiment)
|
||||||
and_(
|
.join(SemesterExperiment)
|
||||||
SemesterExperiment.semester == userActiveSemester(),
|
.where(SemesterExperiment.semester == userActiveSemester())
|
||||||
SemesterExperiment.assistants.any(Assistant.user == current_user),
|
.join(SemesterExperiment.assistants)
|
||||||
)
|
.where(Assistant.user == current_user)
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
number_of_all_experiment_marks = active_semester_experiment_marks_query.count()
|
number_of_all_experiment_marks = get_count(active_semester_experiment_mark_ids_stmt)
|
||||||
|
|
||||||
number_of_missing_final_experiment_marks = active_semester_experiment_marks_query.filter(
|
number_of_missing_final_experiment_marks = get_count(
|
||||||
ExperimentMark.final_experiment_mark == None
|
active_semester_experiment_mark_ids_stmt.where(ExperimentMark.final_experiment_mark == None)
|
||||||
).count()
|
)
|
||||||
|
|
||||||
return self.render(
|
return self.render(
|
||||||
"assistant_index.html",
|
"assistant_index.html",
|
||||||
|
|
Loading…
Reference in a new issue