From e42430d24b3bc902398b7704c6fa851c53a95580 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 11 Apr 2023 23:08:45 +0200 Subject: [PATCH] add merge status --- src/misc/github.rs | 12 ++++++++++-- src/routes/contrib.rs | 16 +++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/misc/github.rs b/src/misc/github.rs index 81f78a7..d8fcf03 100644 --- a/src/misc/github.rs +++ b/src/misc/github.rs @@ -11,9 +11,17 @@ pub struct GithubResponse { #[derive(Deserialize)] pub struct GithubProject { - pub title: String, - pub html_url: String, + pub repository_url: String, pub number: u32, + pub title: String, + pub state: String, + pub pull_request: GithubPullRequest, +} + +#[derive(Deserialize)] +pub struct GithubPullRequest { + pub html_url: String, + pub merged_at: Option, } pub async fn fetch_pr() -> Result { diff --git a/src/routes/contrib.rs b/src/routes/contrib.rs index a9e9a2a..dc778fb 100644 --- a/src/routes/contrib.rs +++ b/src/routes/contrib.rs @@ -16,9 +16,19 @@ pub async fn get_page(config: Config) -> std::string::String { // Fetch latest data from github if let Ok(resp) = fetch_pr().await { println!("Nb: {}", resp.total_count); - resp.items - .iter() - .for_each(|x| println!("[{0} #{2}]({1})", x.title, x.html_url, x.number)); + resp.items.iter().for_each(|x| { + println!( + "[{} #{}]({}) - {}", + x.title, + x.number, + x.pull_request.html_url, + if x.pull_request.merged_at.is_none() { + &x.state + } else { + "merged" + } + ) + }); }; config.tmpl.render(