< Summary

Information
Class: Syki.Back.Features.Student.GetStudentFrequencies.GetStudentFrequenciesService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Student/GetStudentFrequencies/GetStudentFrequenciesService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 22
Uncovered lines: 0
Coverable lines: 22
Total lines: 35
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
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/GetStudentFrequencies/GetStudentFrequenciesService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Student.GetStudentFrequencies;
 2
 33public class GetStudentFrequenciesService(SykiDbContext ctx) : IStudentService
 4{
 5    public async Task<OneOf<List<GetStudentFrequenciesOut>, ErrorOut>> Get(Guid userId, Guid courseCurriculumId)
 6    {
 37        var attendances = await ctx.Attendances.AsNoTracking().Where(x => x.StudentId == userId).ToListAsync();
 8
 169        var classIds = attendances.Select(x => x.ClassId).Distinct();
 310        var classes = await ctx.Classes.AsNoTracking()
 311            .Include(g => g.Discipline)
 312            .Where(x => classIds.Contains(x.Id))
 313            .ToListAsync();
 14
 1015        var disciplineIds = classes.Select(x => x.DisciplineId);
 316        var disciplines = await ctx.CourseCurriculumDisciplines.AsNoTracking()
 317            .Where(x => x.CourseCurriculumId == courseCurriculumId && disciplineIds.Contains(x.DisciplineId))
 318            .ToListAsync();
 19
 320        var classesStudents = await ctx.ClassesStudents.AsNoTracking()
 321            .Where(x => x.SykiStudentId == userId).ToListAsync();
 22
 323        var result = new List<GetStudentFrequenciesOut>();
 2024        foreach (var item in classes)
 25        {
 2926            var period = disciplines.First(x => x.DisciplineId == item.DisciplineId).Period.ToString();
 8027            var lessons = attendances.Count(x => x.ClassId == item.Id);
 8028            var presences = attendances.Count(x => x.ClassId == item.Id && x.Present);
 2929            var status = classesStudents.First(s => s.ClassId == item.Id).StudentDisciplineStatus;
 730            result.Add(new(item.Discipline.Name, period, lessons, presences, status));
 31        }
 32
 1733        return result.OrderBy(x => x.Period).ThenBy(x => x.Name).ToList();
 334    }
 35}