@@ -26,16 +26,17 @@ public async Task<Maybe<string>> GetPostTitleByPostId(string redditPostId, Cance
2626 return reader . TryGetString ( 0 ) ;
2727 }
2828
29- public async IAsyncEnumerable < string > GetPostIdsWithoutTitleFetched ( [ EnumeratorCancellation ] CancellationToken cancellationToken )
29+ public async IAsyncEnumerable < ( string PostId , string ? Title ) > GetPostsWithoutTitleFetched ( [ EnumeratorCancellation ] CancellationToken cancellationToken )
3030 {
3131 await using var connection = _dbConnectionFactory . CreateReadOnlyConnection ( ) ;
32- await using var reader = await connection . ExecuteReader (
33- "SELECT reddit_post_id FROM reddit_posts WHERE post_title IS NULL AND is_title_fetched = 0" ,
32+
33+ var query = connection . QueryUnbuffered < ( string PostId , string ? Title ) > (
34+ "SELECT reddit_post_id AS PostId, post_title AS Title FROM reddit_posts WHERE is_title_fetched = 0" ,
3435 cancellationToken : cancellationToken ) ;
3536
36- while ( await reader . ReadAsync ( cancellationToken ) )
37+ await foreach ( var redditPostId in query )
3738 {
38- yield return reader . GetString ( 0 ) ;
39+ yield return redditPostId ;
3940 }
4041 }
4142
@@ -59,15 +60,4 @@ UPDATE reddit_posts
5960 WHERE reddit_post_id = @redditPostId
6061 """ , new { redditPostId , title } , cancellationToken ) ;
6162 }
62-
63- public async IAsyncEnumerable < string > GetPostsNeedingTitleFetched ( [ EnumeratorCancellation ] CancellationToken cancellationToken )
64- {
65- await using var connection = _dbConnectionFactory . CreateReadOnlyConnection ( ) ;
66-
67- var query = connection . QueryUnbuffered < string > ( "SELECT reddit_post_id FROM reddit_posts WHERE is_title_fetched = 0" ,
68- cancellationToken : cancellationToken ) ;
69-
70- await foreach ( var redditPostId in query )
71- yield return redditPostId ;
72- }
7363}
0 commit comments