< Summary

Information
Class: Syki.Back.Features.Student.GetStudentAverageNote.GetStudentAverageNoteService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Student/GetStudentAverageNote/GetStudentAverageNoteService.cs
Tag: 22_11348620282
Line coverage
92%
Covered lines: 13
Uncovered lines: 1
Coverable lines: 14
Total lines: 24
Line coverage: 92.8%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
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()50%2290.9%

File(s)

/home/runner/work/syki/syki/Back/Features/Student/GetStudentAverageNote/GetStudentAverageNoteService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Student.GetStudentAverageNote;
 2
 43public class GetStudentAverageNoteService(SykiDbContext ctx) : IStudentService
 4{
 5    public async Task<decimal> Get(Guid userId)
 6    {
 47        var classesStudents = await ctx.ClassesStudents.AsNoTracking()
 48            .Where(x =>
 49                x.SykiStudentId == userId &&
 410                x.StudentDisciplineStatus != StudentDisciplineStatus.Pendente &&
 411                x.StudentDisciplineStatus != StudentDisciplineStatus.Matriculado
 412            ).ToListAsync();
 13
 414        var classes = classesStudents.ConvertAll(x => x.ClassId);
 415        var examGrades = await ctx.ExamGrades.AsNoTracking()
 416            .Where(x => x.StudentId == userId).ToListAsync();
 17
 418        var notes = classes.ConvertAll(c => examGrades.Where(g => g.ClassId == c).GetAverageNote());
 19
 820        if (notes.Count == 0) return 0;
 21
 022        return Math.Round(notes.Average(), 2);
 423    }
 24}