manager: Implement pagination for issue fetching
All checks were successful
/ build (push) Successful in 1m6s
All checks were successful
/ build (push) Successful in 1m6s
Forgejo seems to limit requests to 50 issues server side, regardless of the limit we send in our request. This means we have to fetch each page separately regardless.
This commit is contained in:
parent
95991f47d4
commit
c08beba27b
|
@ -2,23 +2,34 @@ use anyhow::Context as _;
|
||||||
|
|
||||||
/// Read all issues to generate the full techtree
|
/// Read all issues to generate the full techtree
|
||||||
pub async fn collect_tree(ctx: &crate::Context) -> anyhow::Result<crate::tree::Tree> {
|
pub async fn collect_tree(ctx: &crate::Context) -> anyhow::Result<crate::tree::Tree> {
|
||||||
let issues = ctx
|
let mut issues = vec![];
|
||||||
.forgejo
|
for page in 1.. {
|
||||||
.issue_list_issues(
|
let new = ctx
|
||||||
&ctx.owner,
|
.forgejo
|
||||||
&ctx.repo,
|
.issue_list_issues(
|
||||||
forgejo_api::structs::IssueListIssuesQuery {
|
&ctx.owner,
|
||||||
// We also want the closed issues
|
&ctx.repo,
|
||||||
state: Some(forgejo_api::structs::IssueListIssuesQueryState::All),
|
forgejo_api::structs::IssueListIssuesQuery {
|
||||||
// No pagination
|
// We also want the closed issues
|
||||||
limit: Some(10000),
|
state: Some(forgejo_api::structs::IssueListIssuesQueryState::All),
|
||||||
// Only issues
|
// We cannot turn off pagination entirely, but let's set the limit as high as
|
||||||
r#type: Some(forgejo_api::structs::IssueListIssuesQueryType::Issues),
|
// Forgejo lets us.
|
||||||
..Default::default()
|
limit: Some(10000),
|
||||||
},
|
page: Some(page),
|
||||||
)
|
// Only issues
|
||||||
.await
|
r#type: Some(forgejo_api::structs::IssueListIssuesQueryType::Issues),
|
||||||
.context("Failed fetching issue list")?;
|
..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 tree = crate::tree::Tree::new();
|
||||||
let mut issue_numbers = Vec::new();
|
let mut issue_numbers = Vec::new();
|
||||||
|
|
Loading…
Reference in a new issue