Skip to content

Commit 77e9591

Browse files
lythixcsharpfritz
authored andcommitted
Changed two methods that were expecting to be awaitable into asynchronous calls, which also fixes the build warnings (#337)
1 parent 27d4e83 commit 77e9591

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

CoreWiki.Application/Articles/Search/Impl/ArticlesDbSearchEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public async Task<SearchResultDto<ArticleSearchDto>> SearchAsync(string query, i
2424
var filteredQuery = query.Trim();
2525
var offset = (pageNumber - 1) * resultsPerPage;
2626

27-
var (articles, totalFound) = _articleRepo.GetArticlesForSearchQuery(filteredQuery, offset, resultsPerPage);
27+
var (articles, totalFound) = await _articleRepo.GetArticlesForSearchQuery(filteredQuery, offset, resultsPerPage);
2828

2929
var result = new SearchResult<Article>
3030
{

CoreWiki.Data.Abstractions/Interfaces/IArticleRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface IArticleRepository : IDisposable
1818

1919
Task<Article> CreateArticleAndHistory(Article article);
2020

21-
(IEnumerable<Article> articles, int totalFound) GetArticlesForSearchQuery(string filteredQuery, int offset, int resultsPerPage);
21+
Task<(IEnumerable<Article> articles, int totalFound)> GetArticlesForSearchQuery(string filteredQuery, int offset, int resultsPerPage);
2222

2323
Task<bool> IsTopicAvailable(string articleSlug, int articleId);
2424

CoreWiki.Data/Repositories/ArticleRepository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public async Task<bool> IsTopicAvailable(string articleSlug, int articleId)
7171
.AnyAsync(a => a.Slug == articleSlug && a.Id != articleId);
7272
}
7373

74-
public (IEnumerable<Article> articles, int totalFound) GetArticlesForSearchQuery(string filteredQuery, int offset, int resultsPerPage)
74+
public async Task<(IEnumerable<Article> articles, int totalFound)> GetArticlesForSearchQuery(string filteredQuery, int offset, int resultsPerPage)
7575
{
7676
// WARNING: This may need to be further refactored to allow for database optimized search queries
7777

@@ -82,7 +82,7 @@ public async Task<bool> IsTopicAvailable(string articleSlug, int articleId)
8282
|| a.Content.ToUpper().Contains(filteredQuery.ToUpper())
8383
).Select(a => a.ToDomain());
8484
var articleCount = articles.Count();
85-
var list = articles.Skip(offset).Take(resultsPerPage).OrderByDescending(a => a.ViewCount).ToList();
85+
var list = await articles.Skip(offset).Take(resultsPerPage).OrderByDescending(a => a.ViewCount).ToListAsync();
8686

8787
return (list, articleCount);
8888
}

CoreWiki/Pages/CreateArticleFromLink.cshtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public async Task<IActionResult> OnPostCreateLinksAsync(string slug)
7171
taskList.Add(_mediator.Send(createCmd));
7272
});
7373

74-
Task.WaitAll(taskList.ToArray());
74+
await Task.WhenAll(taskList.ToArray());
7575

7676
return Redirect($"/wiki/{(slug == UrlHelpers.HomePageSlug ? "" : slug)}");
7777
}

0 commit comments

Comments
 (0)