< Summary

Information
Class: Syki.Back.Features.Teacher.GetTeacherInsights.GetTeacherInsightsService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Teacher/GetTeacherInsights/GetTeacherInsightsService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 17
Uncovered lines: 0
Coverable lines: 17
Total lines: 25
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
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%11100%

File(s)

/home/runner/work/syki/syki/Back/Features/Teacher/GetTeacherInsights/GetTeacherInsightsService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Teacher.GetTeacherInsights;
 2
 13public class GetTeacherInsightsService(SykiDbContext ctx) : ITeacherService
 4{
 5    public async Task<TeacherInsightsOut> Get(Guid institutionId, Guid userId)
 6    {
 17        var classes = await ctx.Classes.AsNoTracking()
 18            .Include(c => c.Students)
 19            .Include(c => c.Lessons)
 110            .Where(x => x.InstitutionId == institutionId && x.TeacherId == userId && x.Status == ClassStatus.Started)
 111            .ToListAsync();
 12
 113        var students = new Dictionary<Guid, Guid>();
 114        var totalLessons = 0;
 115        var finalizedLessons = 0;
 116        classes.ForEach(c =>
 117        {
 1218            c.Students.ForEach(s => students.TryAdd(s.Id, s.Id));
 619            totalLessons += c.Lessons.Count;
 13520            finalizedLessons += c.Lessons.Count(x => x.Status == LessonStatus.Finalized);
 721        });
 22
 123        return new() { Classes = classes.Count, Students = students.Count, TotalLessons = totalLessons, FinalizedLessons
 124    }
 25}