< Summary

Information
Class: Syki.Back.Features.Academic.GetAcademicClasses.GetAcademicClassesService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Academic/GetAcademicClasses/GetAcademicClassesService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 21
Uncovered lines: 0
Coverable lines: 21
Total lines: 35
Line coverage: 100%
Branch coverage
81%
Covered branches: 13
Total branches: 16
Branch coverage: 81.2%
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()78.57%1414100%

File(s)

/home/runner/work/syki/syki/Back/Features/Academic/GetAcademicClasses/GetAcademicClassesService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Academic.GetAcademicClasses;
 2
 43public class GetAcademicClassesService(SykiDbContext ctx) : IAcademicService
 4{
 5    public async Task<List<ClassOut>> Get(Guid institutionId, GetAcademicClassesIn query)
 6    {
 47        var classes = await ctx.Classes.AsNoTracking()
 48            .Include(t => t.Discipline)
 49            .Include(t => t.Teacher)
 410            .Include(t => t.Schedules)
 411            .Include(t => t.Lessons)
 412                .ThenInclude(l => l.Attendances)
 413            .Where(c => c.InstitutionId == institutionId)
 414            .ToListAsync();
 15
 416        var periods = await ctx.EnrollmentPeriods.AsNoTracking().Where(x => x.InstitutionId == institutionId).ToListAsyn
 17
 818        var ids = classes.ConvertAll(x => x.Id);
 419        var links = await ctx.ClassesStudents.AsNoTracking().Where(x => ids.Contains(x.ClassId)).ToListAsync();
 1620        foreach (var @class in classes)
 21        {
 522            var count = links.Count(x => x.ClassId == @class.Id);
 423            @class.SetFillRatio(count);
 24
 625            var period = periods.FirstOrDefault(x => x.Id == @class.PeriodId);
 426            if (@class.Status == ClassStatus.OnEnrollment && period?.EndAt < DateTime.Now.ToDateOnly())
 27            {
 128                @class.Status = ClassStatus.AwaitingStart;
 29            }
 30        }
 31
 432        var status = query?.Status ?? null;
 1133        return classes.Where(x => status == null || x.Status == status).Select(t => t.ToOut()).ToList();
 434    }
 35}