< Summary - Estud

Information
Class: Estud.Back.Features.Students.GetStudentAgenda.GetStudentAgendaService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Students/GetStudentAgenda/GetStudentAgendaService.cs
Tag: 114_29044117136
Line coverage
0%
Covered lines: 0
Uncovered lines: 30
Coverable lines: 30
Total lines: 45
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
Get()0%620%

File(s)

/home/runner/work/syki/syki/Back/Features/Students/GetStudentAgenda/GetStudentAgendaService.cs

#LineLine coverage
 1namespace Estud.Back.Features.Students.GetStudentAgenda;
 2
 03public class GetStudentAgendaService(EstudDbContext ctx) : IEstudService
 4{
 5    public async Task<GetStudentAgendaOut> Get()
 6    {
 07        var studentId = ctx.RequestUser.Id;
 08        var institutionId = ctx.RequestUser.InstitutionId;
 9
 010        var ids = await ctx.ClassStudents.AsNoTracking()
 011            .Where(x => x.StudentId == studentId && x.Status == StudentClassStatus.Matriculado)
 012            .Select(x => x.ClassId)
 013            .ToListAsync();
 14
 015        var classes = await ctx.Classes.AsNoTracking()
 016            .Include(t => t.Discipline)
 017            .Include(t => t.Schedules)
 018            .Where(t => t.InstitutionId == institutionId && ids.Contains(t.Id))
 019            .ToListAsync();
 20
 21        // Pra cada dia, pegar as aulas que acontecem nesse dia, ordenadas pelo horário de início
 022        var days = classes.Select(x => x.Schedules.Select(s => s.Day)).SelectMany(x => x).Distinct().OrderBy(x => x).ToL
 023        var agenda = new List<GetStudentAgendaItemOut>();
 24
 025        foreach (var day in days)
 26        {
 027            var dayClasses = classes.Where(c => c.Schedules.Any(s => s.Day == day)).ToList();
 028            var disciplines = dayClasses.SelectMany(c => c.Schedules.Where(s => s.Day == day).Select(s => new GetStudent
 029            {
 030                ClassId = c.Id,
 031                Name = c.Discipline.Name,
 032                Start = s.Start,
 033                End = s.End
 034            })).OrderBy(d => d.Start).ToList();
 35
 036            agenda.Add(new GetStudentAgendaItemOut
 037            {
 038                Day = day,
 039                Disciplines = disciplines
 040            });
 41        }
 42
 043        return new GetStudentAgendaOut { Days = agenda };
 044    }
 45}