< Summary

Information
Class: OzonOrdersWeb.WebServices.Hangfire.HangfireJobGridRow
Assembly: OzonOrdersWeb
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/WebServices/Hangfire/HangfireJobGridRows.cs
Line coverage
33%
Covered lines: 4
Uncovered lines: 8
Coverable lines: 12
Total lines: 47
Line coverage: 33.3%
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_Id()100%210%
get_Method()100%210%
get_State()100%210%
get_ServerId()100%210%
get_EnqueuedAt()100%210%
get_StartedAt()100%210%
get_SucceededAt()100%210%
get_DeletedAt()100%210%
get_DurationMs()100%11100%
get_Args()100%11100%
get_Result()100%11100%

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>
 27public sealed record HangfireJobGridRow(
 08    string? Id,
 09    string? Method,
 010    string? State,
 011    string? ServerId,
 012    DateTime? EnqueuedAt,
 013    DateTime? StartedAt,
 014    DateTime? SucceededAt,
 015    DateTime? DeletedAt,
 216    long? DurationMs,
 117    string? Args,
 318    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) =>
 32        (jobs ?? []).Select(j => new HangfireJobGridRow(
 33                j.Id,
 34                j.MethodName,
 35                j.State,
 36                j.ServerId,
 37                j.EnqueuedAt,
 38                j.StartedAt,
 39                j.SucceededAt,
 40                j.DeletedAt,
 41                kind == Processing
 42                    ? (long)Math.Max(0, (nowUtc - (j.StartedAt ?? nowUtc)).TotalMilliseconds)
 43                    : j.Duration,
 44                j.Args != null ? JsonConvert.SerializeObject(j.Args, Formatting.Indented) : null,
 45                string.IsNullOrEmpty(j.Result) ? null : j.Result))
 46            .ToList();
 47}