From 16ee22f4d6f1acc8b36eccba730cfc8e0cde4d21 Mon Sep 17 00:00:00 2001 From: olesya-karpets Date: Sun, 9 Jun 2024 10:10:27 +0300 Subject: [PATCH] crud_teacher: edited get_courses_reports() --- src/app/crud/crud_teacher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/crud/crud_teacher.py b/src/app/crud/crud_teacher.py index 1273cb3..aa00e1c 100644 --- a/src/app/crud/crud_teacher.py +++ b/src/app/crud/crud_teacher.py @@ -193,7 +193,7 @@ async def get_courses_reports(db: Session, teacher: Teacher, min_progress: float courses_query = courses_query.order_by(Course.course_id.desc()) result = db.execute(courses_query) #result contains raw SQL rows - courses_with_students = result.scalars().all() # scalars() converts raw SQL rows into ORM objects(Course instances) + courses_with_students = result.scalars().unique().all() # scalars() converts raw SQL rows into ORM objects student_progress_dict = await calculate_student_progresses(db, courses_with_students) courses_reports = generate_reports(courses_with_students, student_progress_dict, min_progress)