< Summary - Syki

Information
Class: Syki.Back.Features.Academic.GetTeachers.GetTeachersService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Academic/GetTeachers/GetTeachersService.cs
Tag: 21_17346963026
Line coverage
100%
Covered lines: 29
Uncovered lines: 0
Coverable lines: 29
Total lines: 36
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
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/Academic/GetTeachers/GetTeachersService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Academic.GetTeachers;
 2
 23public class GetTeachersService(SykiDbContext ctx) : IAcademicService
 4{
 5    public async Task<List<TeacherOut>> Get(Guid institutionId)
 6    {
 27        FormattableString sql = $@"
 28            SELECT
 29                t.id,
 210                t.name,
 211                u.email,
 212                COALESCE(tc.total, 0) AS campi,
 213                COALESCE(td.total, 0) AS disciplines
 214            FROM
 215                syki.teachers t
 216            INNER JOIN
 217                syki.users u ON u.id = t.id
 218            LEFT JOIN (
 219                SELECT syki_teacher_id, COUNT(1) AS total
 220                FROM syki.teachers__campi
 221                GROUP BY syki_teacher_id
 222            ) tc ON tc.syki_teacher_id = t.id
 223            LEFT JOIN (
 224                SELECT syki_teacher_id, COUNT(1) AS total
 225                FROM syki.teachers__disciplines
 226                GROUP BY syki_teacher_id
 227            ) td ON td.syki_teacher_id = t.id
 228            WHERE
 229                u.institution_id = {institutionId}
 230            ORDER BY
 231                t.name
 232        ";
 33
 234        return await ctx.Database.SqlQuery<TeacherOut>(sql).ToListAsync();
 235    }
 36}