|
@@ -7,8 +7,9 @@ use futures::{future::BoxFuture, FutureExt};
|
|
|
use hyper::header::HeaderValue;
|
|
|
use once_cell::sync::OnceCell;
|
|
|
use reqwest::header::{AUTHORIZATION, USER_AGENT};
|
|
|
-use reqwest::{Client, Request, RequestBuilder, Response, StatusCode};
|
|
|
+use reqwest::{Client, Request, RequestBuilder, Response, StatusCode, Url};
|
|
|
use std::{
|
|
|
+ collections::HashMap,
|
|
|
fmt,
|
|
|
time::{Duration, SystemTime},
|
|
|
};
|
|
@@ -929,7 +930,7 @@ impl Repository {
|
|
|
} else {
|
|
|
self.build_issues_url(&filters, include_labels, ordering)
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
let result = client.get(&url);
|
|
|
if use_search_api {
|
|
|
let result = client
|
|
@@ -939,7 +940,7 @@ impl Repository {
|
|
|
issues.extend(result.items);
|
|
|
if issues.len() < result.total_count {
|
|
|
ordering.page += 1;
|
|
|
- continue
|
|
|
+ continue;
|
|
|
}
|
|
|
} else {
|
|
|
// FIXME: paginate with non-search
|
|
@@ -1085,6 +1086,63 @@ impl<'q> IssuesQuery for Query<'q> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// impl<'q> FCPQuery for Query<'q>
|
|
|
+// where
|
|
|
+// Query<'q>: IssuesQuery,
|
|
|
+#[async_trait]
|
|
|
+impl<'q> FCPQuery for IssuesQuery {
|
|
|
+ async fn query_fcp<'a>(
|
|
|
+ &'a self,
|
|
|
+ repo: &'a Repository,
|
|
|
+ client: &'a GithubClient,
|
|
|
+ ) -> anyhow::Result<Vec<crate::rfcbot::FCPDecorator>> {
|
|
|
+ let url = Url::parse(&"https://rfcbot.rs/api/all")?;
|
|
|
+ let res = reqwest::get(url)
|
|
|
+ .await?
|
|
|
+ .json::<Vec<crate::rfcbot::FullFCP>>()
|
|
|
+ .await?;
|
|
|
+
|
|
|
+ let mut map: HashMap<String, crate::rfcbot::FullFCP> = HashMap::new();
|
|
|
+ for full_fcp in res.into_iter() {
|
|
|
+ map.insert(
|
|
|
+ format!(
|
|
|
+ "https://github.com/{}/{}",
|
|
|
+ full_fcp.issue.repository.clone(),
|
|
|
+ full_fcp.issue.number.clone()
|
|
|
+ ),
|
|
|
+ full_fcp,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ let decorators = self.query(&repo, &client).await?;
|
|
|
+
|
|
|
+ let fcp_decorators: Vec<_> = decorators
|
|
|
+ .iter()
|
|
|
+ .filter_map(|issue_decorator| {
|
|
|
+ if let Some(full_fcp) = map.get(&issue_decorator.html_url) {
|
|
|
+ Some(crate::rfcbot::FCPDecorator {
|
|
|
+ number: issue_decorator.number.clone(),
|
|
|
+ title: issue_decorator.title.clone(),
|
|
|
+ html_url: issue_decorator.html_url.clone(),
|
|
|
+ repo_name: issue_decorator.repo_name.clone(),
|
|
|
+ labels: issue_decorator.labels.clone(),
|
|
|
+ assignees: issue_decorator.assignees.clone(),
|
|
|
+ updated_at: issue_decorator.updated_at.clone(),
|
|
|
+
|
|
|
+ bot_tracking_comment: full_fcp.fcp.fk_bot_tracking_comment.to_string(),
|
|
|
+ bot_tracking_comment_content: full_fcp.status_comment.body.clone(),
|
|
|
+ initiating_comment: full_fcp.fcp.fk_initiating_comment.to_string(),
|
|
|
+ initiating_comment_content: String::new(),
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ None
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .collect();
|
|
|
+ Ok(fcp_decorators)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
#[derive(Debug, serde::Deserialize)]
|
|
|
#[serde(rename_all = "snake_case")]
|
|
|
pub enum CreateKind {
|
|
@@ -1377,6 +1435,14 @@ pub trait IssuesQuery {
|
|
|
client: &'a GithubClient,
|
|
|
) -> anyhow::Result<Vec<crate::actions::IssueDecorator>>;
|
|
|
}
|
|
|
+#[async_trait]
|
|
|
+pub trait FCPQuery {
|
|
|
+ async fn query_fcp<'a>(
|
|
|
+ &'a self,
|
|
|
+ repo: &'a Repository,
|
|
|
+ client: &'a GithubClient,
|
|
|
+ ) -> anyhow::Result<Vec<crate::rfcbot::FCPDecorator>>;
|
|
|
+}
|
|
|
|
|
|
#[cfg(test)]
|
|
|
mod tests {
|