< Summary

Information
Class: UIBlazor.Services.RuleService
Assembly: UIBlazor
File(s): /home/runner/work/InvAit/InvAit/UIBlazor/Services/RuleService.cs
Tag: 71_26091983037
Line coverage
0%
Covered lines: 0
Uncovered lines: 21
Coverable lines: 21
Total lines: 53
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 16
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%
GetRulesAsync()0%7280%
GetAgentsMdAsync()0%7280%

File(s)

/home/runner/work/InvAit/InvAit/UIBlazor/Services/RuleService.cs

#LineLine coverage
 1namespace UIBlazor.Services;
 2
 03public class RuleService(IVsBridge vsBridge) : IRuleService
 4{
 5    private string? _rulesCache;
 06    private DateTime _lastCacheUpdate = DateTime.MinValue;
 7    private string? _agentsCache;
 08    private DateTime _lastAgentsCacheUpdate = DateTime.MinValue;
 9
 10    /// <summary>
 11    /// Получить содержимое rules.md (кешируется)
 12    /// </summary>
 13    public async Task<string> GetRulesAsync(CancellationToken cancellationToken)
 14    {
 15        // Проверяем кеш (обновляем раз в 2 минуты)
 016        if (_rulesCache != null && (DateTime.UtcNow - _lastCacheUpdate).TotalMinutes < 2)
 17        {
 018            return _rulesCache;
 19        }
 20
 021        var result = await vsBridge.ExecuteToolAsync(BasicEnum.GetRules, cancellationToken: cancellationToken);
 022        if (!result.Success)
 23        {
 024            return _rulesCache ?? string.Empty;
 25        }
 26
 027        _rulesCache = result.Result;
 028        _lastCacheUpdate = DateTime.UtcNow;
 029        return _rulesCache;
 030    }
 31
 32    /// <summary>
 33    /// Получить содержимое agents.md (кешируется)
 34    /// </summary>
 35    public async Task<string> GetAgentsMdAsync(CancellationToken cancellationToken)
 36    {
 37        // Проверяем кеш (обновляем раз в 2 минуты)
 038        if (_agentsCache != null && (DateTime.UtcNow - _lastAgentsCacheUpdate).TotalMinutes < 2)
 39        {
 040            return _agentsCache;
 41        }
 42
 043        var result = await vsBridge.ExecuteToolAsync(BasicEnum.GetAgents, cancellationToken: cancellationToken);
 044        if (!result.Success)
 45        {
 046            return _agentsCache ?? string.Empty;
 47        }
 48
 049        _agentsCache = result.Result;
 050        _lastAgentsCacheUpdate = DateTime.UtcNow;
 051        return _agentsCache;
 052    }
 53}