< Summary

Information
Class: Syki.Back.Features.Student.GetStudentFrequency.GetStudentFrequencyService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Student/GetStudentFrequency/GetStudentFrequencyService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 15
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
 173public class GetStudentFrequencyService(SykiDbContext ctx) : IStudentService
 4{
 5    public async Task<GetStudentFrequencyOut> Get(Guid userId)
 6    {
 177        var attendances = await ctx.Attendances.Where(x => x.StudentId == userId).CountAsync();
 178        var presences = await ctx.Attendances.Where(x => x.StudentId == userId && x.Present).CountAsync();
 9
 1910        if (attendances == 0) return new() { Frequency = 0, Presences = presences, Attendances = attendances };
 1511        var frequency = Math.Round(100M*(1M * presences / (1M * attendances)), 2);
 12
 1513        return new() { Frequency = frequency, Presences = presences, Attendances = attendances };
 1714    }
 15}