|
@@ -1,7 +1,6 @@
|
|
|
use anyhow::Context;
|
|
|
use async_trait::async_trait;
|
|
|
use chrono::{DateTime, FixedOffset, Utc};
|
|
|
-use futures::future::try_join_all;
|
|
|
use futures::{future::BoxFuture, FutureExt};
|
|
|
use hyper::header::HeaderValue;
|
|
|
use once_cell::sync::OnceCell;
|
|
@@ -1066,72 +1065,70 @@ impl<'q> IssuesQuery for Query<'q> {
|
|
|
.await
|
|
|
.with_context(|| "Unable to get issues.")?;
|
|
|
|
|
|
- let issues_decorator: Vec<_> = issues
|
|
|
- .iter()
|
|
|
- .map(|issue| async move {
|
|
|
- let fcp_details = if include_fcp_details {
|
|
|
- // TODO: this seems like a *really* bad approach, but I'm not sure how to make it better
|
|
|
- let fcp_map = crate::rfcbot::get_all_fcps().await?;
|
|
|
- let repository_name = if let Some(repo) = issue.repository.get() {
|
|
|
- repo.repository.clone()
|
|
|
- } else {
|
|
|
- let re = regex::Regex::new("https://github.com/rust-lang/|/").unwrap();
|
|
|
- let split = re.split(&issue.html_url).collect::<Vec<&str>>();
|
|
|
- split[1].to_string()
|
|
|
- };
|
|
|
- let key = format!(
|
|
|
- "rust-lang/{}:{}:{}",
|
|
|
- repository_name, issue.number, issue.title,
|
|
|
- );
|
|
|
+ let fcp_map = crate::rfcbot::get_all_fcps().await?;
|
|
|
|
|
|
- if let Some(fcp) = fcp_map.get(&key) {
|
|
|
- let bot_tracking_comment_html_url = format!(
|
|
|
- "{}#issuecomment-{}",
|
|
|
- issue.html_url, fcp.fcp.fk_bot_tracking_comment
|
|
|
- );
|
|
|
- let bot_tracking_comment_content = quote_reply(&fcp.status_comment.body);
|
|
|
-
|
|
|
- let fk_initiating_comment = fcp.fcp.fk_initiating_comment;
|
|
|
- let init_comment = issue
|
|
|
- .get_comment(&client, fk_initiating_comment.try_into()?)
|
|
|
- .await?;
|
|
|
-
|
|
|
- Some(crate::actions::FCPDetails {
|
|
|
- bot_tracking_comment_html_url,
|
|
|
- bot_tracking_comment_content,
|
|
|
- initiating_comment_html_url: init_comment.html_url.clone(),
|
|
|
- initiating_comment_content: quote_reply(&init_comment.body),
|
|
|
- })
|
|
|
- } else {
|
|
|
- None
|
|
|
- }
|
|
|
+ let mut issues_decorator = Vec::new();
|
|
|
+ for issue in issues {
|
|
|
+ let fcp_details = if include_fcp_details {
|
|
|
+ let repository_name = if let Some(repo) = issue.repository.get() {
|
|
|
+ repo.repository.clone()
|
|
|
} else {
|
|
|
- None
|
|
|
+ let re = regex::Regex::new("https://github.com/rust-lang/|/").unwrap();
|
|
|
+ let split = re.split(&issue.html_url).collect::<Vec<&str>>();
|
|
|
+ split[1].to_string()
|
|
|
};
|
|
|
- Ok(crate::actions::IssueDecorator {
|
|
|
- title: issue.title.clone(),
|
|
|
- number: issue.number,
|
|
|
- html_url: issue.html_url.clone(),
|
|
|
- repo_name: repo.name().to_owned(),
|
|
|
- labels: issue
|
|
|
- .labels
|
|
|
- .iter()
|
|
|
- .map(|l| l.name.as_ref())
|
|
|
- .collect::<Vec<_>>()
|
|
|
- .join(", "),
|
|
|
- assignees: issue
|
|
|
- .assignees
|
|
|
- .iter()
|
|
|
- .map(|u| u.login.as_ref())
|
|
|
- .collect::<Vec<_>>()
|
|
|
- .join(", "),
|
|
|
- updated_at: crate::actions::to_human(issue.updated_at),
|
|
|
- fcp_details,
|
|
|
- })
|
|
|
- })
|
|
|
- .collect();
|
|
|
+ let key = format!(
|
|
|
+ "rust-lang/{}:{}:{}",
|
|
|
+ repository_name, issue.number, issue.title,
|
|
|
+ );
|
|
|
+
|
|
|
+ if let Some(fcp) = fcp_map.get(&key) {
|
|
|
+ let bot_tracking_comment_html_url = format!(
|
|
|
+ "{}#issuecomment-{}",
|
|
|
+ issue.html_url, fcp.fcp.fk_bot_tracking_comment
|
|
|
+ );
|
|
|
+ let bot_tracking_comment_content = quote_reply(&fcp.status_comment.body);
|
|
|
+
|
|
|
+ let fk_initiating_comment = fcp.fcp.fk_initiating_comment;
|
|
|
+ let init_comment = issue
|
|
|
+ .get_comment(&client, fk_initiating_comment.try_into()?)
|
|
|
+ .await?;
|
|
|
+
|
|
|
+ Some(crate::actions::FCPDetails {
|
|
|
+ bot_tracking_comment_html_url,
|
|
|
+ bot_tracking_comment_content,
|
|
|
+ initiating_comment_html_url: init_comment.html_url.clone(),
|
|
|
+ initiating_comment_content: quote_reply(&init_comment.body),
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ None
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ None
|
|
|
+ };
|
|
|
+ issues_decorator.push(crate::actions::IssueDecorator {
|
|
|
+ title: issue.title.clone(),
|
|
|
+ number: issue.number,
|
|
|
+ html_url: issue.html_url.clone(),
|
|
|
+ repo_name: repo.name().to_owned(),
|
|
|
+ labels: issue
|
|
|
+ .labels
|
|
|
+ .iter()
|
|
|
+ .map(|l| l.name.as_ref())
|
|
|
+ .collect::<Vec<_>>()
|
|
|
+ .join(", "),
|
|
|
+ assignees: issue
|
|
|
+ .assignees
|
|
|
+ .iter()
|
|
|
+ .map(|u| u.login.as_ref())
|
|
|
+ .collect::<Vec<_>>()
|
|
|
+ .join(", "),
|
|
|
+ updated_at: crate::actions::to_human(issue.updated_at),
|
|
|
+ fcp_details,
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- try_join_all(issues_decorator).await
|
|
|
+ Ok(issues_decorator)
|
|
|
}
|
|
|
}
|
|
|
|