diff --git a/techtree-manager/src/collect.rs b/techtree-manager/src/collect.rs index 8fa3654..c0034ed 100644 --- a/techtree-manager/src/collect.rs +++ b/techtree-manager/src/collect.rs @@ -2,23 +2,34 @@ use anyhow::Context as _; /// Read all issues to generate the full techtree pub async fn collect_tree(ctx: &crate::Context) -> anyhow::Result { - let issues = ctx - .forgejo - .issue_list_issues( - &ctx.owner, - &ctx.repo, - forgejo_api::structs::IssueListIssuesQuery { - // We also want the closed issues - state: Some(forgejo_api::structs::IssueListIssuesQueryState::All), - // No pagination - limit: Some(10000), - // Only issues - r#type: Some(forgejo_api::structs::IssueListIssuesQueryType::Issues), - ..Default::default() - }, - ) - .await - .context("Failed fetching issue list")?; + let mut issues = vec![]; + for page in 1.. { + let new = ctx + .forgejo + .issue_list_issues( + &ctx.owner, + &ctx.repo, + forgejo_api::structs::IssueListIssuesQuery { + // We also want the closed issues + state: Some(forgejo_api::structs::IssueListIssuesQueryState::All), + // We cannot turn off pagination entirely, but let's set the limit as high as + // Forgejo lets us. + limit: Some(10000), + page: Some(page), + // Only issues + r#type: Some(forgejo_api::structs::IssueListIssuesQueryType::Issues), + ..Default::default() + }, + ) + .await + .with_context(|| format!("Failed fetching page {page} of the issue list"))?; + + if new.len() == 0 { + break; + } + + issues.extend(new); + } let mut tree = crate::tree::Tree::new(); let mut issue_numbers = Vec::new();