|
@@ -1,4 +1,5 @@
|
|
|
-use futures::executor::block_on;
|
|
|
+use async_trait::async_trait;
|
|
|
+
|
|
|
use reqwest::Client;
|
|
|
use std::env;
|
|
|
use std::fs::File;
|
|
@@ -12,8 +13,9 @@ pub struct Meeting<A: Action> {
|
|
|
pub steps: Vec<A>,
|
|
|
}
|
|
|
|
|
|
+#[async_trait]
|
|
|
pub trait Action {
|
|
|
- fn call(&self) -> String;
|
|
|
+ async fn call(&self) -> String;
|
|
|
}
|
|
|
|
|
|
pub struct Step<'a> {
|
|
@@ -46,45 +48,43 @@ pub struct FileTemplate<'a> {
|
|
|
map: Vec<(&'a str, Vec<Issue>)>,
|
|
|
}
|
|
|
|
|
|
+#[async_trait]
|
|
|
impl<'a> Action for Step<'a> {
|
|
|
- fn call(&self) -> String {
|
|
|
+ async fn call(&self) -> String {
|
|
|
let gh = GithubClient::new(
|
|
|
Client::new(),
|
|
|
env::var("GITHUB_API_TOKEN").expect("Missing GITHUB_API_TOKEN"),
|
|
|
);
|
|
|
|
|
|
- let map = self
|
|
|
- .actions
|
|
|
- .iter()
|
|
|
- .flat_map(|RepoQuery { repo, queries }| {
|
|
|
- let repository = Repository {
|
|
|
- full_name: repo.to_string(),
|
|
|
- };
|
|
|
-
|
|
|
- queries
|
|
|
- .iter()
|
|
|
- .map(|NamedQuery { name, query }| {
|
|
|
- let issues_search_result = block_on(repository.get_issues(
|
|
|
- &gh,
|
|
|
- &query.filters,
|
|
|
- &query.include_labels,
|
|
|
- &query.exclude_labels,
|
|
|
- ));
|
|
|
-
|
|
|
- match issues_search_result {
|
|
|
- Ok(issues) => (*name, issues),
|
|
|
- Err(err) => {
|
|
|
- eprintln!("ERROR: {}", err);
|
|
|
- err.chain()
|
|
|
- .skip(1)
|
|
|
- .for_each(|cause| eprintln!("because: {}", cause));
|
|
|
- std::process::exit(1);
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- .collect::<Vec<_>>()
|
|
|
- })
|
|
|
- .collect();
|
|
|
+ let mut map = Vec::new();
|
|
|
+
|
|
|
+ for RepoQuery { repo, queries } in &self.actions {
|
|
|
+ let repository = Repository {
|
|
|
+ full_name: repo.to_string(),
|
|
|
+ };
|
|
|
+
|
|
|
+ for NamedQuery { name, query } in queries {
|
|
|
+ let issues_search_result = repository
|
|
|
+ .get_issues(
|
|
|
+ &gh,
|
|
|
+ &query.filters,
|
|
|
+ &query.include_labels,
|
|
|
+ &query.exclude_labels,
|
|
|
+ )
|
|
|
+ .await;
|
|
|
+
|
|
|
+ match issues_search_result {
|
|
|
+ Ok(issues) => map.push((*name, issues)),
|
|
|
+ Err(err) => {
|
|
|
+ eprintln!("ERROR: {}", err);
|
|
|
+ err.chain()
|
|
|
+ .skip(1)
|
|
|
+ .for_each(|cause| eprintln!("because: {}", cause));
|
|
|
+ std::process::exit(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
let template = FileTemplate::new(self.name, map);
|
|
|
template.render()
|