< Summary

Information
Class: OzonOrdersWeb.WebServices.Hangfire.HangfireJobGridRows
Assembly: OzonOrdersWeb
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/WebServices/Hangfire/HangfireJobGridRows.cs
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 47
Line coverage: 100%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Build(...)83.33%66100%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/WebServices/Hangfire/HangfireJobGridRows.cs

#LineLine coverage
 1using Newtonsoft.Json;
 2using Services.HangfireService.Models;
 3
 4namespace OzonOrdersWeb.WebServices.Hangfire;
 5
 6/// <summary>Строка грида очереди Hangfire: аргументы уже сериализованы, длительность — в миллисекундах.</summary>
 7public sealed record HangfireJobGridRow(
 8    string? Id,
 9    string? Method,
 10    string? State,
 11    string? ServerId,
 12    DateTime? EnqueuedAt,
 13    DateTime? StartedAt,
 14    DateTime? SucceededAt,
 15    DateTime? DeletedAt,
 16    long? DurationMs,
 17    string? Args,
 18    string? Result);
 19
 20/// <summary>Вкладки очереди Hangfire (В очереди / Выполняются / Выполненные / Удалённые) → строки гридов.</summary>
 21public static class HangfireJobGridRows
 22{
 23    public const string Enqueued = "enqueued";
 24    public const string Processing = "processing";
 25    public const string Succeeded = "succeeded";
 26    public const string Deleted = "deleted";
 27
 28    /// <summary>
 29    /// Для выполняющихся длительность считается от StartedAt до <paramref name="nowUtc"/>; для выполненных — из Hangfir
 30    /// </summary>
 31    public static List<HangfireJobGridRow> Build(string kind, IEnumerable<JobDto>? jobs, DateTime nowUtc) =>
 532        (jobs ?? []).Select(j => new HangfireJobGridRow(
 533                j.Id,
 534                j.MethodName,
 535                j.State,
 536                j.ServerId,
 537                j.EnqueuedAt,
 538                j.StartedAt,
 539                j.SucceededAt,
 540                j.DeletedAt,
 541                kind == Processing
 542                    ? (long)Math.Max(0, (nowUtc - (j.StartedAt ?? nowUtc)).TotalMilliseconds)
 543                    : j.Duration,
 544                j.Args != null ? JsonConvert.SerializeObject(j.Args, Formatting.Indented) : null,
 545                string.IsNullOrEmpty(j.Result) ? null : j.Result))
 346            .ToList();
 47}