[backend/razor] Add batch retry functionality to the queue dashboard (ISH-494)
This commit is contained in:
parent
13614c2201
commit
1e650d8649
3 changed files with 47 additions and 2 deletions
|
@ -98,7 +98,6 @@ public class AdminController(
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("queue/jobs/{id::guid}/retry")]
|
[HttpPost("queue/jobs/{id::guid}/retry")]
|
||||||
[Produces(MediaTypeNames.Application.Json)]
|
|
||||||
[ProducesResults(HttpStatusCode.OK)]
|
[ProducesResults(HttpStatusCode.OK)]
|
||||||
[ProducesErrors(HttpStatusCode.BadRequest, HttpStatusCode.NotFound)]
|
[ProducesErrors(HttpStatusCode.BadRequest, HttpStatusCode.NotFound)]
|
||||||
public async Task RetryQueueJob(Guid id)
|
public async Task RetryQueueJob(Guid id)
|
||||||
|
@ -109,6 +108,32 @@ public class AdminController(
|
||||||
await queueSvc.RetryJobAsync(job);
|
await queueSvc.RetryJobAsync(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("queue/{queue}/retry-all")]
|
||||||
|
[ProducesResults(HttpStatusCode.OK)]
|
||||||
|
public async Task RetryFailedJobs(string queue)
|
||||||
|
{
|
||||||
|
var jobs = db.Jobs
|
||||||
|
.Where(p => p.Queue == queue && p.Status == Job.JobStatus.Failed)
|
||||||
|
.AsChunkedAsyncEnumerable(10);
|
||||||
|
|
||||||
|
await foreach (var job in jobs)
|
||||||
|
await queueSvc.RetryJobAsync(job);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("queue/{queue}/retry-range/{from::guid}/{to::guid}")]
|
||||||
|
[ProducesResults(HttpStatusCode.OK)]
|
||||||
|
public async Task RetryRange(string queue, Guid from, Guid to)
|
||||||
|
{
|
||||||
|
var jobs = db.Jobs
|
||||||
|
.Where(p => p.Queue == queue && p.Status == Job.JobStatus.Failed)
|
||||||
|
.Where(p => p.Id >= from && p.Id <= to)
|
||||||
|
.AsChunkedAsyncEnumerable(10);
|
||||||
|
|
||||||
|
await foreach (var job in jobs)
|
||||||
|
await queueSvc.RetryJobAsync(job);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[UseNewtonsoftJson]
|
[UseNewtonsoftJson]
|
||||||
[HttpGet("activities/notes/{id}")]
|
[HttpGet("activities/notes/{id}")]
|
||||||
[OverrideResultType<ASNote>]
|
[OverrideResultType<ASNote>]
|
||||||
|
|
|
@ -91,7 +91,13 @@ else
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<p>Listing @Model.TotalCount <span class="status-@Model.Filter.Value.ToString().ToLowerInvariant()">@Model.Filter.Value.ToString().ToLowerInvariant()</span> <b>@Model.Queue</b> jobs.</p>
|
<p>
|
||||||
|
Listing @Model.TotalCount <span class="status-@Model.Filter.Value.ToString().ToLowerInvariant()">@Model.Filter.Value.ToString().ToLowerInvariant()</span> <b>@Model.Queue</b> jobs.
|
||||||
|
@if (Model.Filter is Job.JobStatus.Failed)
|
||||||
|
{
|
||||||
|
<span>Batch retry: <a class="fake-link" onclick="retryAllFailed('@Model.Queue')">all failed</a> / <a class="fake-link" onclick="retryAllOnPage('@Model.Queue')">all on this page</a></span>
|
||||||
|
}
|
||||||
|
</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
<table class="auto-table">
|
<table class="auto-table">
|
||||||
|
|
|
@ -49,3 +49,17 @@ async function retry(id) {
|
||||||
await callApiMethod(`/api/iceshrimp/admin/queue/jobs/${id}/retry`);
|
await callApiMethod(`/api/iceshrimp/admin/queue/jobs/${id}/retry`);
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function retryAllFailed(queue) {
|
||||||
|
await callApiMethod(`/api/iceshrimp/admin/queue/${queue}/retry-all`);
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function retryAllOnPage(queue) {
|
||||||
|
const elements = document.getElementsByClassName("uuid");
|
||||||
|
const items = Array.prototype.map.call(elements, x => x.textContent).sort();
|
||||||
|
const first = items[0];
|
||||||
|
const last = items[items.length - 1];
|
||||||
|
await callApiMethod(`/api/iceshrimp/admin/queue/${queue}/retry-range/${first}/${last}`);
|
||||||
|
window.location.reload();
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue