< Summary

Information
Class: OzonOrdersWeb.WebServices.Transactions.Grid.Commit.Steps.AiCommentStep
Assembly: OzonOrdersWeb
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/WebServices/Transactions/Grid/Commit/Steps/AiCommentStep.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 16
Coverable lines: 16
Total lines: 40
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 10
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%
get_Key()100%210%
ExecuteAsync()0%7280%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/WebServices/Transactions/Grid/Commit/Steps/AiCommentStep.cs

#LineLine coverage
 1using OzonOrdersWeb.TransactionServices;
 2using OzonRepositories.Context;
 3using Services.TransactionCommentAi;
 4
 5namespace OzonOrdersWeb.WebServices.Transactions.Grid.Commit.Steps;
 6
 7/// <summary>Постановка AI-комментария в очередь, если пользователь не написал свой.</summary>
 8public sealed class AiCommentStep : ITransactionCommitStep
 9{
 10    private readonly ApplicationDbContext _context;
 11
 012    public AiCommentStep(ApplicationDbContext context)
 13    {
 014        _context = context;
 015    }
 16
 017    public string Key => TransactionCommitStepKeys.AiComment;
 18
 19    public async Task ExecuteAsync(TransactionCommitContext ctx)
 20    {
 021        var flow = ctx.CommentFlow;
 022        if (!flow.ScheduleAiComment || flow.Builder == null || ctx.TransactionId <= 0)
 23        {
 024            return;
 25        }
 26
 027        if (ctx.OzonShipResult is OrderToSupplierOzonShipResult ship)
 28        {
 029            flow.Builder.WithOzonShip(TransactionCommentAiOzonShipMapper.ToSummary(ship));
 30        }
 31
 032        var changedFieldsByOrder = ctx.OrdersToTransaction.ToDictionary(
 033            o => o.Id,
 034            o => (o.UpdatedColumns ?? new List<string>()).Where(c => !string.IsNullOrWhiteSpace(c)).Distinct().ToList())
 35
 036        await TransactionCommentAiSchedulingHelper.TryScheduleAsync(
 037            ctx.Services, flow.Builder, flow.ScheduleAiComment, ctx.TransactionId, ctx.OrdersToTransaction,
 038            ctx.FromStatusByOrderId, _context, changedFieldsByOrder, ctx.CancellationToken);
 039    }
 40}