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.template import EndpointLinkRowAction
|
||||
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 .models import (
|
||||
Assistant,
|
||||
|
@ -39,15 +40,17 @@ class SecureAdminIndexView(CustomIndexView):
|
|||
|
||||
@expose("/")
|
||||
def index(self):
|
||||
active_semester_experiment_marks_query = ExperimentMark.query.filter(
|
||||
ExperimentMark.part_student.has(PartStudent.part.has(Part.semester == userActiveSemester()))
|
||||
active_semester_experiment_mark_ids_stmt = (
|
||||
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 = active_semester_experiment_marks_query.filter(
|
||||
ExperimentMark.final_experiment_mark == None
|
||||
).count()
|
||||
number_of_missing_final_experiment_marks = get_count(
|
||||
active_semester_experiment_mark_ids_stmt.where(ExperimentMark.final_experiment_mark == None)
|
||||
)
|
||||
|
||||
return self.render(
|
||||
"admin_index.html",
|
||||
|
@ -62,22 +65,20 @@ class SecureAssistantIndexView(CustomIndexView):
|
|||
|
||||
@expose("/")
|
||||
def index(self):
|
||||
active_semester_experiment_marks_query = ExperimentMark.query.filter(
|
||||
ExperimentMark.group_experiment.has(
|
||||
GroupExperiment.semester_experiment.has(
|
||||
and_(
|
||||
SemesterExperiment.semester == userActiveSemester(),
|
||||
SemesterExperiment.assistants.any(Assistant.user == current_user),
|
||||
)
|
||||
)
|
||||
)
|
||||
active_semester_experiment_mark_ids_stmt = (
|
||||
select(ExperimentMark.final_experiment_mark)
|
||||
.join(GroupExperiment)
|
||||
.join(SemesterExperiment)
|
||||
.where(SemesterExperiment.semester == userActiveSemester())
|
||||
.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(
|
||||
ExperimentMark.final_experiment_mark == None
|
||||
).count()
|
||||
number_of_missing_final_experiment_marks = get_count(
|
||||
active_semester_experiment_mark_ids_stmt.where(ExperimentMark.final_experiment_mark == None)
|
||||
)
|
||||
|
||||
return self.render(
|
||||
"assistant_index.html",
|
||||
|
|
Loading…
Reference in a new issue