< Summary

Information
Class: Syki.Back.Features.Student.GetStudentExamGrades.GetStudentExamGradesService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Student/GetStudentExamGrades/GetStudentExamGradesService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 31
Uncovered lines: 0
Coverable lines: 31
Total lines: 42
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Get()100%11100%

File(s)

/home/runner/work/syki/syki/Back/Features/Student/GetStudentExamGrades/GetStudentExamGradesService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Student.GetStudentExamGrades;
 2
 23public class GetStudentExamGradesService(SykiDbContext ctx) : IStudentService
 4{
 5    public async Task<List<StudentExamGradeOut>> Get(Guid userId)
 6    {
 27        var classesStudents = await ctx.ClassesStudents.AsNoTracking()
 28            .Where(x => x.SykiStudentId == userId).ToListAsync();
 9
 1410        var classesIds = classesStudents.ConvertAll(x => x.ClassId);
 211        var classes = await ctx.Classes.AsNoTracking()
 212            .Include(x => x.Discipline)
 213            .Select(x => new { ClassId = x.Id, x.DisciplineId, Discipline = x.Discipline.Name })
 214            .Where(x => classesIds.Contains(x.ClassId))
 215            .ToListAsync();
 16
 1417        var disciplinesIds = classes.ConvertAll(x => x.DisciplineId);
 218        var periods = await ctx.CourseCurriculumDisciplines.AsNoTracking()
 219            .Select(x => new { x.DisciplineId, x.Period })
 220            .Where(x => disciplinesIds.Contains(x.DisciplineId))
 221            .ToListAsync();
 22
 223        var examGrades = await ctx.ExamGrades.AsNoTracking()
 224            .Where(x => x.StudentId == userId).ToListAsync();
 25
 226        var result = classes.ConvertAll(c =>
 227        {
 22828            var disciplineExamGrades = examGrades.Where(g => g.ClassId == c.ClassId).ToList();
 1229            return new StudentExamGradeOut
 1230            {
 1231                ClassId = c.ClassId,
 1232                Discipline = c.Discipline,
 1233                AverageNote = disciplineExamGrades.GetAverageNote(),
 3634                ExamGrades = disciplineExamGrades.Select(g => g.ToOut()).ToList(),
 4235                Period = periods.First(p => p.DisciplineId == c.DisciplineId).Period,
 4236                StudentDisciplineStatus = classesStudents.First(s => s.ClassId == c.ClassId).StudentDisciplineStatus,
 1237            };
 238        });
 39
 2640        return result.OrderBy(x => x.Period).ThenBy(x => x.Discipline).ToList();
 241    }
 42}