< Summary

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

#LineLine coverage
 1using Dapper;
 2using Npgsql;
 3
 4namespace Syki.Back.Features.Adm.GetUsers;
 5
 16public class GetUsersService(DatabaseSettings dbSettings) : IAdmService
 7{
 8    public async Task<List<UserOut>> Get()
 9    {
 110        using var connection = new NpgsqlConnection(dbSettings.ConnectionString);
 11
 12        const string sql = @"
 13            SELECT
 14                u.id,
 15                u.name AS name,
 16                u.email,
 17                i.name AS institution,
 18                STRING_AGG(r.name, ',') AS role
 19            FROM
 20                syki.users u
 21            INNER JOIN
 22                syki.institutions i ON i.id = u.institution_id
 23            INNER JOIN
 24                syki.user_roles ur ON ur.user_id = u.id
 25            INNER JOIN
 26                syki.roles r ON r.id = ur.role_id
 27            GROUP BY
 28                u.id, i.name
 29        ";
 30
 131        var data = await connection.QueryAsync<UserOut>(sql);
 32
 133        return data.ToList();
 134    }
 35}