diff --git a/Iceshrimp.Backend/Controllers/Web/AdminController.cs b/Iceshrimp.Backend/Controllers/Web/AdminController.cs index 0b8e48a8..12571bfc 100644 --- a/Iceshrimp.Backend/Controllers/Web/AdminController.cs +++ b/Iceshrimp.Backend/Controllers/Web/AdminController.cs @@ -98,7 +98,6 @@ public class AdminController( } [HttpPost("queue/jobs/{id::guid}/retry")] - [Produces(MediaTypeNames.Application.Json)] [ProducesResults(HttpStatusCode.OK)] [ProducesErrors(HttpStatusCode.BadRequest, HttpStatusCode.NotFound)] public async Task RetryQueueJob(Guid id) @@ -109,6 +108,32 @@ public class AdminController( 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] [HttpGet("activities/notes/{id}")] [OverrideResultType] diff --git a/Iceshrimp.Backend/Pages/Queue.cshtml b/Iceshrimp.Backend/Pages/Queue.cshtml index 49cbe750..89729343 100644 --- a/Iceshrimp.Backend/Pages/Queue.cshtml +++ b/Iceshrimp.Backend/Pages/Queue.cshtml @@ -91,7 +91,13 @@ else } else { -

Listing @Model.TotalCount @Model.Filter.Value.ToString().ToLowerInvariant() @Model.Queue jobs.

+

+ Listing @Model.TotalCount @Model.Filter.Value.ToString().ToLowerInvariant() @Model.Queue jobs. + @if (Model.Filter is Job.JobStatus.Failed) + { + Batch retry: all failed / all on this page + } +

} diff --git a/Iceshrimp.Backend/wwwroot/js/queue.js b/Iceshrimp.Backend/wwwroot/js/queue.js index a0705887..110c28c9 100644 --- a/Iceshrimp.Backend/wwwroot/js/queue.js +++ b/Iceshrimp.Backend/wwwroot/js/queue.js @@ -48,4 +48,18 @@ async function callApiMethod(route) { async function retry(id) { await callApiMethod(`/api/iceshrimp/admin/queue/jobs/${id}/retry`); 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(); } \ No newline at end of file