< Summary

Information
Class: Services.BackgroundJobsServices.TransactionJobRetryScheduler
Assembly: Services
File(s): /home/runner/work/Studio2Prod/Studio2Prod/AppRepository/BackgroundJobsServices/TransactionJobRetryScheduler.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 28
Coverable lines: 28
Total lines: 57
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
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%
ScheduleScheduledRetry(...)0%620%
ScheduleManualRetry(...)0%2040%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/AppRepository/BackgroundJobsServices/TransactionJobRetryScheduler.cs

#LineLine coverage
 1using Hangfire;
 2
 3namespace Services.BackgroundJobsServices;
 4
 5public interface ITransactionJobRetryScheduler
 6{
 7    void ScheduleScheduledRetry(int scheduleId, string jobType, int retryAttempt);
 8    void ScheduleManualRetry(int ozonClientId, int daysBack, string jobType, string? signalRJobId, int retryAttempt);
 9}
 10
 11public class TransactionJobRetryScheduler : ITransactionJobRetryScheduler
 12{
 13    private readonly IBackgroundJobClient _backgroundJobClient;
 14
 015    public TransactionJobRetryScheduler(IBackgroundJobClient backgroundJobClient)
 16    {
 017        _backgroundJobClient = backgroundJobClient;
 018    }
 19
 20    public void ScheduleScheduledRetry(int scheduleId, string jobType, int retryAttempt)
 21    {
 022        var delay = TransactionJobRetryPolicy.GetDelayForAttempt(retryAttempt);
 23
 024        if (string.Equals(jobType, "CustomerReturn", StringComparison.OrdinalIgnoreCase))
 25        {
 026            _backgroundJobClient.Schedule<IAutomatedTransactionProcessingService>(
 027                service => service.ProcessCustomerReturnScheduledRetryAsync(scheduleId, retryAttempt, CancellationToken.
 028                delay);
 029            return;
 30        }
 31
 032        _backgroundJobClient.Schedule<IAutomatedTransactionProcessingService>(
 033            service => service.ProcessShippedToCommissionerScheduledRetryAsync(scheduleId, retryAttempt, CancellationTok
 034            delay);
 035    }
 36
 37    public void ScheduleManualRetry(int ozonClientId, int daysBack, string jobType, string? signalRJobId, int retryAttem
 38    {
 039        var delay = TransactionJobRetryPolicy.GetDelayForAttempt(retryAttempt);
 040        var jobId = string.IsNullOrWhiteSpace(signalRJobId)
 041            ? $"manual-retry-{retryAttempt}-{Guid.NewGuid():N}"[..24]
 042            : signalRJobId.Trim();
 043        if (string.Equals(jobType, "CustomerReturn", StringComparison.OrdinalIgnoreCase))
 44        {
 045            _backgroundJobClient.Schedule<IAutomatedTransactionProcessingService>(
 046                service => service.ProcessCustomerReturnManualRetryAsync(
 047                    ozonClientId, daysBack, jobId, retryAttempt, CancellationToken.None),
 048                delay);
 049            return;
 50        }
 51
 052        _backgroundJobClient.Schedule<IAutomatedTransactionProcessingService>(
 053            service => service.ProcessShippedToCommissionerManualRetryAsync(
 054                ozonClientId, daysBack, jobId, retryAttempt, CancellationToken.None),
 055            delay);
 056    }
 57}