< Summary

Information
Class: UIBlazor.Services.RuleService
Assembly: UIBlazor
File(s): /home/runner/work/InvAit/InvAit/UIBlazor/Services/RuleService.cs
Tag: 14_22728831704
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 39
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
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%
RefreshCacheAsync()100%210%

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
 8    /// <summary>
 9    /// Получить содержимое rules.md (кешируется)
 10    /// </summary>
 11    public async Task<string> GetRulesAsync()
 12    {
 13        // Проверяем кеш (обновляем раз в 2 минуты)
 014        if (_rulesCache != null && (DateTime.UtcNow - _lastCacheUpdate).TotalMinutes < 2)
 15        {
 016            return _rulesCache;
 17        }
 18
 019        var result = await vsBridge.ExecuteToolAsync(BasicEnum.GetRules);
 020        if (!result.Success)
 21        {
 022            return _rulesCache ?? string.Empty;
 23        }
 24
 025        _rulesCache = result.Result;
 026        _lastCacheUpdate = DateTime.UtcNow;
 027        return _rulesCache;
 028    }
 29
 30    /// <summary>
 31    /// Принудительно обновить кеш правил
 32    /// </summary>
 33    public Task RefreshCacheAsync()
 34    {
 035        _lastCacheUpdate = DateTime.MinValue; // Сбрасываем кеш
 036        _rulesCache = null;
 037        return Task.CompletedTask;
 38    }
 39}