do link calls in parallel, so that we're not _horrendously_ slow

pull/178/head
Chet Husk 2022-11-04 12:16:13 -05:00
parent f49b3215a8
commit 21e709ca79
1 changed files with 2 additions and 2 deletions

View File

@ -33,8 +33,8 @@ public static class ShowsApi
.Take(limit)
.Select(x => new ShowDto(x))
.ToListAsync(cancellationToken);
var showsWithValidLinks =
shows.Where(show => showClient.CheckLink(show.Link).Result).ToList();
List<ShowDto> showsWithValidLinks = Task.WhenAll(shows.Select(async show => await showClient.CheckLink(show.Link) ? show : null)).Result.Where(show => show is not null).ToList()!;
return TypedResults.Ok(showsWithValidLinks);
}