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();
|
|
|
|
let client = net.client();
|
|
|
|
let request = client.get(url);
|
2024-09-20 07:23:36 +01:00
|
|
|
let request = if let Some(auth_token) = config.auth_token() {
|
2024-11-14 20:15:36 +00:00
|
|
|
request.header("Authorization", auth_token)
|
2024-09-20 07:23:36 +01:00
|
|
|
} else {
|
2024-11-14 20:15:36 +00:00
|
|
|
request
|
|
|
|
};
|
|
|
|
// .build();
|
2024-09-20 07:23:36 +01:00
|
|
|
|
2024-11-14 20:15:36 +00:00
|
|
|
let response = net.send(request).await?;
|
|
|
|
let issues: HashSet<Issue> = response.json().await?;
|
2024-09-20 07:23:36 +01:00
|
|
|
|
|
|
|
Ok(issues)
|
|
|
|
}
|