< Summary

Information
Class: Syki.Back.Features.Academic.GetAcademicClass.GetAcademicClassService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Academic/GetAcademicClass/GetAcademicClassService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 19
Uncovered lines: 0
Coverable lines: 19
Total lines: 31
Line coverage: 100%
Branch coverage
80%
Covered branches: 8
Total branches: 10
Branch coverage: 80%
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()80%1010100%

File(s)

/home/runner/work/syki/syki/Back/Features/Academic/GetAcademicClass/GetAcademicClassService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Academic.GetAcademicClass;
 2
 103public class GetAcademicClassService(SykiDbContext ctx) : IAcademicService
 4{
 5    public async Task<OneOf<GetAcademicClassOut, SykiError>> Get(Guid institutionId, Guid id)
 6    {
 107        var @class = await ctx.Classes.AsNoTracking()
 108            .Include(t => t.Discipline)
 109            .Include(t => t.Teacher)
 1010            .Include(t => t.Schedules)
 1011            .Include(t => t.Lessons)
 1012                .ThenInclude(l => l.Attendances)
 1013            .Include(t => t.Students)
 1014            .Include(t => t.ExamGrades)
 1015            .Where(c => c.InstitutionId == institutionId && c.Id == id)
 1016            .FirstOrDefaultAsync();
 17
 1118        if (@class == null) return new ClassNotFound();
 19
 920        var count = await ctx.ClassesStudents.Where(x => x.ClassId == id).CountAsync();
 921        @class.SetFillRatio(count);
 22
 923        var period = await ctx.EnrollmentPeriods.AsNoTracking().Where(x => x.InstitutionId == institutionId && x.Id == @
 924        if (@class.Status == ClassStatus.OnEnrollment && period?.EndAt < DateTime.Now.ToDateOnly())
 25        {
 126            @class.Status = ClassStatus.AwaitingStart;
 27        }
 28
 929        return @class.ToGetAcademicClassOut();
 1030    }
 31}