From cbc3e1ebb5d5a2a8557d1ee9e8c00231d8714349 Mon Sep 17 00:00:00 2001 From: meskill <8974488+meskill@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:21:43 +0000 Subject: [PATCH] fix: leaderboard ignore prs without score --- src/bin/github-collect-leaderboard.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/bin/github-collect-leaderboard.rs b/src/bin/github-collect-leaderboard.rs index 3724bee..1744aaa 100644 --- a/src/bin/github-collect-leaderboard.rs +++ b/src/bin/github-collect-leaderboard.rs @@ -1,4 +1,6 @@ -use anyhow::{bail, Context, Result}; +use std::convert::identity; + +use anyhow::{Context, Result}; use octocrate::{APIConfig, GitHubAPI, PersonalAccessToken}; use regex::Regex; use tokio::task::JoinSet; @@ -36,7 +38,7 @@ async fn run() -> Result<()> { .into_iter() .filter(|pr| pr.labels.iter().any(|label| label.name == "ci: benchmark")); - let mut join_set: JoinSet> = JoinSet::new(); + let mut join_set: JoinSet>> = JoinSet::new(); info!("Check score comments for every pr"); @@ -56,29 +58,32 @@ async fn run() -> Result<()> { if comment.performed_via_github_app.is_some() { if let Some(body) = comment.body { if let Some(caps) = score_regex.captures(&body) { - return Ok(Score { + return Ok(Some(Score { author: format!( "_{}_", pr.user.context("Failed to resolve author")?.login ), score: caps[1].parse()?, - }); + })); } } } } - bail!("Failed to infer the score") + Ok(None) }); } info!("Got scores"); - let mut scores = join_set + let mut scores: Vec<_> = join_set .join_all() .await .into_iter() - .collect::>>()?; + .collect::>>()? + .into_iter() + .filter_map(identity) + .collect(); scores.push(Score { author: "**Tailcall**".to_owned(),