< Summary - Syki

Information
Class: Syki.Back.Features.Cross.SeedInstitutionData.SeedInstitutionLessonAttendancesCommandHandler
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Cross/SeedInstitutionData/SeedInstitutionLessonAttendancesCommand.cs
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 17
Coverable lines: 17
Total lines: 33
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
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%
Handle()0%4260%

File(s)

/home/runner/work/syki/syki/Back/Features/Cross/SeedInstitutionData/SeedInstitutionLessonAttendancesCommand.cs

#LineLine coverage
 1using Syki.Back.Features.Teacher.CreateLessonAttendance;
 2
 3namespace Syki.Back.Features.Cross.SeedInstitutionData;
 4
 5[CommandDescription("Realizar seed de chamadas da instituição")]
 6public record SeedInstitutionLessonAttendancesCommand(Guid InstitutionId) : ICommand;
 7
 08public class SeedInstitutionLessonAttendancesCommandHandler(
 09    SykiDbContext ctx,
 010    CreateLessonAttendanceService createLessonAttendanceService) : ICommandHandler<SeedInstitutionLessonAttendancesComma
 11{
 12    public async Task Handle(CommandId commandId, SeedInstitutionLessonAttendancesCommand command)
 13    {
 014        var id = command.InstitutionId;
 15
 016        var classes = await ctx.Classes.AsNoTracking()
 017            .Include(c => c.Lessons)
 018            .Include(c => c.Students)
 019            .Where(c => c.InstitutionId == id)
 020            .ToListAsync();
 21
 022        var random = new Random();
 023        var today = DateTime.UtcNow.ToDateOnly();
 024        foreach (var @class in classes)
 25        {
 026            foreach (var lesson in @class.Lessons.Where(l => l.Date < today))
 27            {
 028                var presentStudents = @class.Students.Select(s => s.Id).PickRandom(random.Next(3, 7)).ToList();
 029                await createLessonAttendanceService.CreateWithThrowOnError(@class.TeacherId!.Value, lesson.Id, new() { P
 30            }
 031        }
 032    }
 33}