コメント調整
This commit is contained in:
1 parent
49e0fa41e3
commit
5e0202ba31
1 file changed
-3
@@ -337,7 +337,6 @@ app.MapGet("/missav123", async () =>
|
|||||||
// --- APIエンドポイントの定義 ---
|
// --- APIエンドポイントの定義 ---
|
||||||
app.MapGet("/momonga/fanzine", async (HttpContext context, IHttpClientFactory httpClientFactory) =>
|
app.MapGet("/momonga/fanzine", async (HttpContext context, IHttpClientFactory httpClientFactory) =>
|
||||||
{
|
{
|
||||||
// 1. 取得対象のURLを10件定義(例として連番パラメーターを生成)
|
|
||||||
var linkList = new List<string>();
|
var linkList = new List<string>();
|
||||||
var pageMaster = "https://momon-ga.com/fanzine";
|
var pageMaster = "https://momon-ga.com/fanzine";
|
||||||
for (int pageId = 1; pageId <= 50; pageId++)
|
for (int pageId = 1; pageId <= 50; pageId++)
|
||||||
@@ -356,7 +355,6 @@ app.MapGet("/momonga/fanzine", async (HttpContext context, IHttpClientFactory ht
|
|||||||
|
|
||||||
var client = httpClientFactory.CreateClient();
|
var client = httpClientFactory.CreateClient();
|
||||||
|
|
||||||
// 2. 10件のRSSを「非同期」かつ「並列」で取得し、メモリに展開せずストリームのままパース
|
|
||||||
var fetchTasks = linkList.Select(async url =>
|
var fetchTasks = linkList.Select(async url =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -375,7 +373,6 @@ app.MapGet("/momonga/fanzine", async (HttpContext context, IHttpClientFactory ht
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 3. 全10件の通信完了を待機し、結果のリストを1つに平坦化 (SelectMany)
|
|
||||||
var results = await Task.WhenAll(fetchTasks);
|
var results = await Task.WhenAll(fetchTasks);
|
||||||
var allItems = results.SelectMany(items => items).ToList();
|
var allItems = results.SelectMany(items => items).ToList();
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user