< Summary - Syki

Information
Class: Syki.Back.Features.Adm.GetCommand.GetCommandService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Adm/GetCommand/GetCommandService.cs
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 12
Coverable lines: 12
Total lines: 52
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
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%2040%

File(s)

/home/runner/work/syki/syki/Back/Features/Adm/GetCommand/GetCommandService.cs

#LineLine coverage
 1using Dapper;
 2using Npgsql;
 3
 4namespace Syki.Back.Features.Adm.GetCommand;
 5
 06public class GetCommandService(NpgsqlDataSource dataSource) : IAdmService
 7{
 8    public async Task<CommandOut> Get(Guid id)
 9    {
 010        await using var connection = await dataSource.OpenConnectionAsync();
 11
 12        const string sql = @"
 13            SELECT *
 14            FROM syki.commands
 15            WHERE id = @Id
 16        ";
 017        var command = await connection.QueryFirstOrDefaultAsync<CommandOut>(sql, new { id }) ?? new();
 018        command.Description = command.Type.ToCommandDescription();
 19
 20        const string sourceBatchSql = @"
 21            SELECT id
 22            FROM syki.command_batches
 23            WHERE next_command_id = @Id
 24        ";
 025        command.SourceBatchId = await connection.QueryFirstOrDefaultAsync<Guid?>(sourceBatchSql, new { id });
 26
 27        const string retriesSql = @"
 28            SELECT *
 29            FROM syki.commands
 30            WHERE original_id = @Id
 31        ";
 032        command.Retries = (await connection.QueryAsync<CommandOut>(retriesSql, new { id })).ToList();
 033        command.Retries.ForEach(x => x.Description = x.Type.ToCommandDescription());
 34
 35        const string subcommandsSql = @"
 36            SELECT *
 37            FROM syki.commands
 38            WHERE parent_id = @Id
 39        ";
 040        command.Subcommands = (await connection.QueryAsync<CommandOut>(subcommandsSql, new { id })).ToList();
 041        command.Subcommands.ForEach(x => x.Description = x.Type.ToCommandDescription());
 42
 43        const string bacthesSql = @"
 44            SELECT *
 45            FROM syki.command_batches
 46            WHERE source_command_id = @Id
 47        ";
 048        command.Batches = (await connection.QueryAsync<BatchOut>(bacthesSql, new { id })).ToList();
 49
 050        return command;
 051    }
 52}