Skip to content

Commit dbf9842

Browse files
committed
feat: add endpoint for title back-fill status
1 parent 39ec0a8 commit dbf9842

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

ApplicationData/Services/RedditPostProvider.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,12 @@ UPDATE reddit_posts
5959
WHERE reddit_post_id = @redditPostId
6060
""", new { redditPostId, title }, cancellationToken);
6161
}
62+
63+
public async Task<int> GetPostsNeedingTitleFetchedCount(CancellationToken cancellationToken)
64+
{
65+
await using var connection = _dbConnectionFactory.CreateReadOnlyConnection();
66+
return await connection.ExecuteScalar<int>(
67+
"SELECT COUNT(*) FROM reddit_posts WHERE is_title_fetched = 0",
68+
cancellationToken: cancellationToken);
69+
}
6270
}

WebApi/Controllers/Admin/AdminQueueController.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ namespace WebApi.Controllers.Admin;
1515
public class AdminQueueController : Controller
1616
{
1717
private readonly LinkProvider _linkProvider;
18+
private readonly RedditPostProvider _redditPostProvider;
1819

1920
/// <inheritdoc />
2021
public AdminQueueController(
21-
LinkProvider linkProvider
22+
LinkProvider linkProvider,
23+
RedditPostProvider redditPostProvider
2224
)
2325
{
2426
_linkProvider = linkProvider;
27+
_redditPostProvider = redditPostProvider;
2528
}
2629

2730
/// <summary>
@@ -46,4 +49,19 @@ public async Task<IActionResult> GetProcessingQueue(CancellationToken cancellati
4649
queuedItems = postIdsWithPendingChanges,
4750
});
4851
}
52+
53+
/// <summary>
54+
/// Get the posts needing their title fetched
55+
/// </summary>
56+
[HttpGet]
57+
[Route("post-title-backlog")]
58+
public async Task<IActionResult> GetPostTitleFetchBacklog(CancellationToken cancellationToken)
59+
{
60+
var count = await _redditPostProvider.GetPostsNeedingTitleFetchedCount(cancellationToken);
61+
62+
return new OkObjectResult(new
63+
{
64+
postsNeedingTitleFetchedCount = count,
65+
});
66+
}
4967
}

0 commit comments

Comments
 (0)