< Summary

Information
Line coverage
0%
Covered lines: 0
Uncovered lines: 22
Coverable lines: 22
Total lines: 56
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%
Index(...)100%210%
DeleteJob(...)0%2040%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/Areas/Studio2/Controllers/HangfireQueueController.cs

#LineLine coverage
 1using Hangfire;
 2using Hangfire.Storage;
 3using Hangfire.Storage.Monitoring;
 4using Microsoft.AspNetCore.Mvc;
 5using System.Collections.Generic;
 6using System.Linq;
 7
 8// Controllers/HangfireQueueController.cs
 9using Microsoft.AspNetCore.Authorization;
 10using OzonOrdersWeb.Areas.Studio2.ViewModels.HangfireQueue;
 11using Services.HangfireService;
 12
 13[Authorize(Roles = "User,Admin")]
 14[Area("Studio2")]
 15public class HangfireQueueController : Controller
 16{
 17    private readonly IHangfireService _hangfireService;
 18
 019    public HangfireQueueController(IHangfireService hangfireService)
 20    {
 021        _hangfireService = hangfireService;
 022    }
 23
 24    public IActionResult Index(string queueName = "main", string tab = "enqueued")
 25    {
 026        var queues = _hangfireService.GetAvailableQueues();
 027        var model = new HangfireJobsViewModel
 028        {
 029            QueueName = queueName,
 030            ActiveTab = tab,
 031            AvailableQueues = queues.ToList(),
 032
 033            EnqueuedJobs = _hangfireService.GetEnqueuedJobs(queueName),
 034            ProcessingJobs = _hangfireService.GetProcessingJobs(queueName),
 035            SucceededJobs = _hangfireService.GetSucceededJobs(),
 036            DeletedJobs = _hangfireService.GetDeletedJobs()
 037        };
 38
 039        return View(model);
 40    }
 41
 42    [HttpPost]
 43    [ValidateAntiForgeryToken]
 44    public IActionResult DeleteJob([FromBody] DeleteJobRequest request)
 45    {
 046        if (string.IsNullOrEmpty(request.JobId))
 047            return BadRequest();
 48
 049        var success = BackgroundJob.Delete(request.JobId);
 50
 051        if (success)
 052            return Ok();
 53        else
 054            return NotFound(); // Задание не найдено или уже завершено
 55    }
 56}