Skip to content

Commit

Permalink
[suiop] add interactive incident selection (#19186)
Browse files Browse the repository at this point in the history
## Description 

Allow interactive incident review selection with suiop

## Test plan 

Successful e2e test in #test-notifications

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
after-ephemera authored Sep 5, 2024
1 parent a831de6 commit d275762
Show file tree
Hide file tree
Showing 8 changed files with 434 additions and 101 deletions.
7 changes: 4 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions crates/suiop-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,23 @@ open = "5.1.2"
prettytable-rs.workspace = true
rand.workspace = true
regex.workspace = true
reqwest = {workspace = true, features = [
reqwest = { workspace = true, features = [
"rustls-tls",
"json",
], default-features = false}
], default-features = false }
semver.workspace = true
serde = {workspace = true, features = ["derive"]}
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
serde_yaml.workspace = true
sha2 = "0.10.6"
spinners.workspace = true
strum.workspace = true
tabled.workspace = true
tokio = {workspace = true, features = ["full"]}
tokio = { workspace = true, features = ["full"] }
toml_edit.workspace = true
tracing-subscriber.workspace = true
tracing.workspace = true
once_cell.workspace = true

[dev-dependencies]
tempfile.workspace = true
19 changes: 17 additions & 2 deletions crates/suiop-cli/src/cli/incidents/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

mod jira;
mod pd;
mod slack;

use anyhow::Result;
use chrono::{Duration, Local};
use clap::Parser;
use jira::generate_follow_up_tasks;
use pd::print_recent_incidents;
use pd::{fetch_incidents, print_recent_incidents, review_recent_incidents};
use std::path::PathBuf;

#[derive(Parser, Debug, Clone)]
Expand All @@ -33,6 +35,8 @@ pub enum IncidentsAction {
/// limit to incidents with any priority set
#[arg(long, short = 'p', default_value = "false")]
with_priority: bool,
#[arg(short, long, default_value = "false")]
interactive: bool,
},
/// generate Jira tasks for incident follow ups
#[command(name = "generate follow up tasks", aliases=["g", "gen", "generate"])]
Expand All @@ -50,7 +54,18 @@ pub async fn incidents_cmd(args: &IncidentsArgs) -> Result<()> {
limit,
days,
with_priority,
} => print_recent_incidents(*long, *limit, *days, *with_priority).await?,
interactive,
} => {
let current_time = Local::now();
let start_time = current_time - Duration::days(*days as i64);

let incidents = fetch_incidents(*limit, start_time, current_time).await?;
if *interactive {
review_recent_incidents(incidents).await?
} else {
print_recent_incidents(incidents, *long, *with_priority).await?
}
}
IncidentsAction::GenerateFollowUpTasks { input_filename } => {
generate_follow_up_tasks(input_filename).await?
}
Expand Down
Loading

0 comments on commit d275762

Please sign in to comment.