2024-11-14 20:15:36 +00:00
|
|
|
//
|
2024-09-20 14:36:01 +01:00
|
|
|
use std::collections::HashSet;
|
|
|
|
|
2024-09-20 07:23:36 +01:00
|
|
|
use crate::model::Config;
|
|
|
|
|
|
|
|
use anyhow::Result;
|
|
|
|
|
|
|
|
use super::Issue;
|
|
|
|
|
2024-11-14 20:15:36 +00:00
|
|
|
pub async fn fetch_open_issues<'net, 'fs>(config: &Config<'net, 'fs>) -> Result<HashSet<Issue>> {
|
2024-09-20 07:23:36 +01:00
|
|
|
let server_url = config.server();
|
|
|
|
let repo = config.repo();
|
|
|
|
let url = format!("{server_url}/api/v1/repos/{repo}/issues?state=open");
|
2024-11-14 20:15:36 +00:00
|
|
|
let net = config.net();
|
2024-11-20 22:45:37 +00:00
|
|
|
let response = net
|
|
|
|
.get(url)
|
|
|
|
.with_option(config.auth_token())
|
|
|
|
.some(|request, auth_token| request.header("Authorization", auth_token))
|
|
|
|
.send()
|
|
|
|
.await?;
|
2024-11-14 20:15:36 +00:00
|
|
|
let issues: HashSet<Issue> = response.json().await?;
|
2024-09-20 07:23:36 +01:00
|
|
|
|
|
|
|
Ok(issues)
|
|
|
|
}
|