< Summary

Information
Class: OzonOrdersWeb.WebServices.Orders.OrdersClientStatusRefreshJob
Assembly: OzonOrdersWeb
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/WebServices/Orders/OrdersClientStatusRefreshJob.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 19
Coverable lines: 19
Total lines: 46
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%
ExecuteAsync()0%2040%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/WebServices/Orders/OrdersClientStatusRefreshJob.cs

#LineLine coverage
 1using System.Diagnostics;
 2using Hangfire;
 3using Microsoft.Extensions.Logging;
 4using Services.CacheServices.Cache.OzonOrdersCache;
 5using Services.HangfireService;
 6
 7namespace OzonOrdersWeb.WebServices.Orders;
 8
 9/// <summary>
 10/// Выполняет запросы статусов, поставленные при открытии списка заказов, вне HTTP-потока.
 11/// </summary>
 12public sealed class OrdersClientStatusRefreshJob
 13{
 14    private readonly IOrdersClientStatusSyncService _statusSync;
 15    private readonly OrderCache _orderCache;
 16    private readonly ILogger<OrdersClientStatusRefreshJob> _logger;
 17
 018    public OrdersClientStatusRefreshJob(
 019        IOrdersClientStatusSyncService statusSync,
 020        OrderCache orderCache,
 021        ILogger<OrdersClientStatusRefreshJob> logger)
 22    {
 023        _statusSync = statusSync;
 024        _orderCache = orderCache;
 025        _logger = logger;
 026    }
 27
 28    [Queue(HangfireQueueNames.OrderStatusSync)]
 29    [DisableConcurrentExecution(timeoutInSeconds: 60)]
 30    [AutomaticRetry(Attempts = 1)]
 31    public async Task ExecuteAsync(int[] orderIds)
 32    {
 033        var ids = orderIds.Distinct().Take(100).ToArray();
 034        if (ids.Length == 0)
 035            return;
 36
 037        var stopwatch = Stopwatch.StartNew();
 038        var result = await _statusSync.SyncOrderStatusesAsync(ids);
 039        await _orderCache.RemoveOrdersFromCache(ids);
 040        stopwatch.Stop();
 41
 042        _logger.LogInformation(
 043            "Фоновая синхронизация Ozon-статусов: {Count} заказов за {ElapsedMs} мс; ошибка: {Error}",
 044            ids.Length, stopwatch.ElapsedMilliseconds, result.Error ?? "нет");
 045    }
 46}