This commit is contained in:
Rahix 2026-03-01 15:23:57 +01:00
commit 1db4778dc4
8 changed files with 2410 additions and 0 deletions

41
src/collect.rs Normal file
View file

@ -0,0 +1,41 @@
use crate::task;
use anyhow::Context as _;
pub async fn collect_tasks(ctx: &crate::Context) -> anyhow::Result<Vec<task::Task>> {
let issues = list_all_issues(ctx).await?;
let issues: Vec<_> = issues
.iter()
.map(|i| {
format!(
"#{} — {}",
i.number.unwrap_or(-1),
i.title.as_deref().unwrap_or("")
)
})
.collect();
dbg!(issues);
todo!()
}
async fn list_all_issues(ctx: &crate::Context) -> anyhow::Result<Vec<forgejo_api::structs::Issue>> {
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),
// Only issues
r#type: Some(forgejo_api::structs::IssueListIssuesQueryType::Issues),
..Default::default()
},
)
.all()
.await
.with_context(|| format!("Failed fetching issue list"))?;
Ok(issues)
}