< Summary - Syki

Information
Class: Syki.Back.Features.Student.GetStudentFrequency.GetStudentFrequencyService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Student/GetStudentFrequency/GetStudentFrequencyService.cs
Tag: 4_16869239191
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 26
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
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%22100%

File(s)

/home/runner/work/syki/syki/Back/Features/Student/GetStudentFrequency/GetStudentFrequencyService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Student.GetStudentFrequency;
 2
 363public class GetStudentFrequencyService(SykiDbContext ctx) : IStudentService
 4{
 5    public async Task<GetStudentFrequencyOut> Get(Guid userId)
 6    {
 367        var result = new GetStudentFrequencyOut();
 8
 369        result.Attendances = await ctx.Attendances.Where(x => x.StudentId == userId).CountAsync();
 3610        result.Presences = await ctx.Attendances.Where(x => x.StudentId == userId && x.Present).CountAsync();
 3611        result.Absences = result.Attendances - result.Presences;
 12
 3613        var classesIds = await ctx.ClassesStudents
 3614            .Where(x => x.SykiStudentId == userId)
 3615            .Select(x => x.ClassId).ToListAsync();
 3616        result.TotalLessons = await ctx.Lessons.AsNoTracking()
 3617            .Where(x => classesIds.Contains(x.ClassId))
 3618            .CountAsync();
 19
 4020        if (result.Attendances == 0) return result;
 21
 3222        result.Frequency = Math.Round(100M*(1M * result.Presences / (1M * result.Attendances)), 2);
 23
 3224        return result;
 3625    }
 26}