update workloads statistics endpoint for coordinator
This commit is contained in:
parent
856372e5ab
commit
afffc78537
@ -6,7 +6,7 @@ from .groups import bp as groups_bp
|
||||
from .project_supervisor import bp as project_supervisor_bp
|
||||
from .students import bp as students_bp
|
||||
from .year_group import bp as year_group_bp
|
||||
# from .workloads import bp as workloads_bp
|
||||
from .workloads import bp as workloads_bp
|
||||
|
||||
bp = Blueprint("coordinator", __name__, url_prefix="/coordinator")
|
||||
|
||||
@ -16,4 +16,4 @@ bp.register_blueprint(groups_bp)
|
||||
bp.register_blueprint(year_group_bp)
|
||||
bp.register_blueprint(examination_schedule_bp)
|
||||
bp.register_blueprint(enrollments_bp)
|
||||
# bp.register_blueprint(workloads_bp)
|
||||
bp.register_blueprint(workloads_bp)
|
||||
|
@ -72,7 +72,7 @@ def create_project_supervisor(data: dict) -> dict:
|
||||
return {"message": "Project Supervisor was created!"}
|
||||
|
||||
|
||||
@bp.get("/<int:id>/")
|
||||
@bp.get("/<int:id>/detail")
|
||||
@bp.output(ProjectSupervisorSchema)
|
||||
def detail_project_supervisor(id: int) -> ProjectSupervisor:
|
||||
project_supervisor = ProjectSupervisor.query.filter_by(id=id).first()
|
||||
|
@ -3,7 +3,7 @@ from flask import abort
|
||||
from flask_sqlalchemy import get_debug_queries
|
||||
|
||||
from ...dependencies import db
|
||||
from ...examination_schedule.models import ExaminationSchedule
|
||||
from ...examination_schedule.models import ExaminationSchedule, TermOfDefence
|
||||
from ...project_supervisor.models import ProjectSupervisor
|
||||
from ..schemas import WorkloadSchema
|
||||
|
||||
@ -19,15 +19,14 @@ def workloads_statistics(examination_schedule_id: int) -> dict:
|
||||
|
||||
statistics = db.session.query(
|
||||
ProjectSupervisor.first_name + " " + ProjectSupervisor.last_name,
|
||||
db.func.count(Enrollment.group_id),
|
||||
db.func.count(Committee.id),
|
||||
).join(Committee.members). \
|
||||
join(Enrollment, isouter=True). \
|
||||
db.func.count(TermOfDefence.group_id),
|
||||
db.func.count(TermOfDefence.id),
|
||||
).join(TermOfDefence.members_of_committee). \
|
||||
group_by(ProjectSupervisor.id).all()
|
||||
|
||||
# print(statistics)
|
||||
# print(len(statistics))
|
||||
# print(get_debug_queries())
|
||||
workloads = ({"full_name": s[0], "groups_assigned_to_his_committee": s[1], "assigned_to_committee": s[2]} for s in
|
||||
statistics)
|
||||
workloads = ({"full_name": s[0], "groups_assigned_to_his_committee": s[1],
|
||||
"assigned_to_committee": s[2]} for s in statistics)
|
||||
return {'workloads': workloads}
|
||||
|
Loading…
Reference in New Issue
Block a user