Skip to content

Commit 13208bb

Browse files
committed
feat: add processing queue admin endpoint
1 parent da6527c commit 13208bb

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using ApplicationData.Services;
2+
using Microsoft.AspNetCore.Mvc;
3+
4+
namespace WebApi.Controllers.Admin;
5+
6+
/// <summary>
7+
/// Admin Queue controller
8+
/// </summary>
9+
[Route("v1/admin/queue")]
10+
public class AdminQueueController : AdminApiController
11+
{
12+
private readonly LinkProvider _linkProvider;
13+
14+
/// <inheritdoc />
15+
public AdminQueueController(
16+
IServiceProvider serviceProvider,
17+
LinkProvider linkProvider
18+
) : base(serviceProvider)
19+
{
20+
_linkProvider = linkProvider;
21+
}
22+
23+
/// <summary>
24+
/// Retrieve the processing queue
25+
/// </summary>
26+
[HttpGet]
27+
[Route("")]
28+
public async Task<IActionResult> GetProcessingQueue(CancellationToken cancellationToken)
29+
{
30+
var postIdsWithPendingChanges = await _linkProvider.GetRedditPostIdsWithPendingChanges(cancellationToken)
31+
.Select(x => new
32+
{
33+
queuedItemId = x.QueuedItemId,
34+
redditPostId = x.RedditPostId,
35+
queuedAt = x.QueuedAt,
36+
})
37+
.ToArrayAsync(cancellationToken);
38+
39+
return new OkObjectResult(new
40+
{
41+
itemCount = postIdsWithPendingChanges.Length,
42+
queuedItems = postIdsWithPendingChanges,
43+
});
44+
}
45+
}

0 commit comments

Comments
 (0)