Skip to content

Commit

Permalink
archived_cli
Browse files Browse the repository at this point in the history
  • Loading branch information
epompeii committed Jul 10, 2024
1 parent 6130d85 commit a034224
Show file tree
Hide file tree
Showing 21 changed files with 186 additions and 40 deletions.
14 changes: 13 additions & 1 deletion services/cli/src/bencher/sub/project/alert/list.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bencher_client::types::{JsonDirection, ProjAlertsSort};
use bencher_client::types::{AlertStatus, JsonDirection, ProjAlertsSort};
use bencher_json::ResourceId;

use crate::{
Expand All @@ -14,6 +14,8 @@ use crate::{
pub struct List {
pub project: ResourceId,
pub pagination: Pagination,
pub status: Option<AlertStatus>,
pub archived: bool,
pub backend: PubBackend,
}

Expand All @@ -32,11 +34,15 @@ impl TryFrom<CliAlertList> for List {
let CliAlertList {
project,
pagination,
status,
archived,
backend,
} = list;
Ok(Self {
project,
pagination: pagination.into(),
status: status.map(Into::into),
archived,
backend: backend.try_into()?,
})
}
Expand Down Expand Up @@ -80,6 +86,12 @@ impl SubCmd for List {
if let Some(page) = self.pagination.page {
client = client.page(page);
}
if let Some(status) = self.status {
client = client.status(status);
}
if self.archived {
client = client.archived(self.archived);
}
client.send().await
})
.await?;
Expand Down
17 changes: 16 additions & 1 deletion services/cli/src/bencher/sub/project/alert/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
use crate::{bencher::sub::SubCmd, parser::project::alert::CliAlert, CliError};
use bencher_client::types::AlertStatus;

use crate::{
bencher::sub::SubCmd,
parser::project::alert::{CliAlert, CliAlertStatus},
CliError,
};

mod list;
mod update;
Expand Down Expand Up @@ -32,3 +38,12 @@ impl SubCmd for Alert {
}
}
}

impl From<CliAlertStatus> for AlertStatus {
fn from(status: CliAlertStatus) -> Self {
match status {
CliAlertStatus::Active => Self::Active,
CliAlertStatus::Dismissed => Self::Dismissed,
}
}
}
11 changes: 1 addition & 10 deletions services/cli/src/bencher/sub/project/alert/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bencher_json::{AlertUuid, ResourceId};

use crate::{
bencher::{backend::AuthBackend, sub::SubCmd},
parser::project::alert::{CliAlertStatus, CliAlertUpdate},
parser::project::alert::CliAlertUpdate,
CliError,
};

Expand Down Expand Up @@ -34,15 +34,6 @@ impl TryFrom<CliAlertUpdate> for Update {
}
}

impl From<CliAlertStatus> for AlertStatus {
fn from(status: CliAlertStatus) -> Self {
match status {
CliAlertStatus::Active => Self::Active,
CliAlertStatus::Dismissed => Self::Dismissed,
}
}
}

impl From<Update> for JsonUpdateAlert {
fn from(update: Update) -> Self {
let Update { status, .. } = update;
Expand Down
6 changes: 6 additions & 0 deletions services/cli/src/bencher/sub/project/benchmark/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct List {
pub name: Option<BenchmarkName>,
pub search: Option<String>,
pub pagination: Pagination,
pub archived: bool,
pub backend: PubBackend,
}

Expand All @@ -36,13 +37,15 @@ impl TryFrom<CliBenchmarkList> for List {
name,
search,
pagination,
archived,
backend,
} = list;
Ok(Self {
project,
name,
search,
pagination: pagination.into(),
archived,
backend: backend.try_into()?,
})
}
Expand Down Expand Up @@ -91,6 +94,9 @@ impl SubCmd for List {
if let Some(page) = self.pagination.page {
client = client.page(page);
}
if self.archived {
client = client.archived(self.archived);
}
client.send().await
})
.await?;
Expand Down
11 changes: 10 additions & 1 deletion services/cli/src/bencher/sub/project/benchmark/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct Update {
pub benchmark: ResourceId,
pub name: Option<BenchmarkName>,
pub slug: Option<Slug>,
pub archived: Option<bool>,
pub backend: AuthBackend,
}

Expand All @@ -25,24 +26,32 @@ impl TryFrom<CliBenchmarkUpdate> for Update {
benchmark,
name,
slug,
archived,
backend,
} = create;
Ok(Self {
project,
benchmark,
name,
slug,
archived: archived.into(),
backend: backend.try_into()?,
})
}
}

impl From<Update> for JsonUpdateBenchmark {
fn from(update: Update) -> Self {
let Update { name, slug, .. } = update;
let Update {
name,
slug,
archived,
..
} = update;
Self {
name: name.map(Into::into),
slug: slug.map(Into::into),
archived,
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions services/cli/src/bencher/sub/project/branch/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct List {
pub name: Option<BranchName>,
pub search: Option<String>,
pub pagination: Pagination,
pub archived: bool,
pub backend: PubBackend,
}

Expand All @@ -36,13 +37,15 @@ impl TryFrom<CliBranchList> for List {
name,
search,
pagination,
archived,
backend,
} = list;
Ok(Self {
project,
name,
search,
pagination: pagination.into(),
archived,
backend: backend.try_into()?,
})
}
Expand Down Expand Up @@ -91,6 +94,9 @@ impl SubCmd for List {
if let Some(page) = self.pagination.page {
client = client.page(page);
}
if self.archived {
client = client.archived(self.archived);
}
client.send().await
})
.await?;
Expand Down
15 changes: 9 additions & 6 deletions services/cli/src/bencher/sub/project/branch/update.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bencher_client::types::JsonUpdateBranch;
use bencher_json::{BranchName, GitHash, ResourceId, Slug};
use bencher_json::{BranchName, ResourceId, Slug};

use crate::{
bencher::{backend::AuthBackend, sub::SubCmd},
Expand All @@ -13,7 +13,7 @@ pub struct Update {
pub branch: ResourceId,
pub name: Option<BranchName>,
pub slug: Option<Slug>,
pub hash: Option<GitHash>,
pub archived: Option<bool>,
pub backend: AuthBackend,
}

Expand All @@ -26,15 +26,15 @@ impl TryFrom<CliBranchUpdate> for Update {
branch,
name,
slug,
hash,
archived,
backend,
} = create;
Ok(Self {
project,
branch,
name,
slug,
hash,
archived: archived.into(),
backend: backend.try_into()?,
})
}
Expand All @@ -43,12 +43,15 @@ impl TryFrom<CliBranchUpdate> for Update {
impl From<Update> for JsonUpdateBranch {
fn from(update: Update) -> Self {
let Update {
name, slug, hash, ..
name,
slug,
archived,
..
} = update;
Self {
name: name.map(Into::into),
slug: slug.map(Into::into),
hash: hash.map(Into::into),
archived,
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions services/cli/src/bencher/sub/project/measure/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct List {
pub name: Option<ResourceName>,
pub search: Option<String>,
pub pagination: Pagination,
pub archived: bool,
pub backend: PubBackend,
}

Expand All @@ -36,13 +37,15 @@ impl TryFrom<CliMeasureList> for List {
name,
search,
pagination,
archived,
backend,
} = list;
Ok(Self {
project,
name,
search,
pagination: pagination.into(),
archived,
backend: backend.try_into()?,
})
}
Expand Down Expand Up @@ -91,6 +94,9 @@ impl SubCmd for List {
if let Some(page) = self.pagination.page {
client = client.page(page);
}
if self.archived {
client = client.archived(self.archived);
}
client.send().await
})
.await?;
Expand Down
10 changes: 9 additions & 1 deletion services/cli/src/bencher/sub/project/measure/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct Update {
pub name: Option<ResourceName>,
pub slug: Option<Slug>,
pub units: Option<ResourceName>,
pub archived: Option<bool>,
pub backend: AuthBackend,
}

Expand All @@ -27,6 +28,7 @@ impl TryFrom<CliMeasureUpdate> for Update {
name,
slug,
units,
archived,
backend,
} = create;
Ok(Self {
Expand All @@ -35,6 +37,7 @@ impl TryFrom<CliMeasureUpdate> for Update {
name,
slug,
units,
archived: archived.into(),
backend: backend.try_into()?,
})
}
Expand All @@ -43,12 +46,17 @@ impl TryFrom<CliMeasureUpdate> for Update {
impl From<Update> for JsonUpdateMeasure {
fn from(update: Update) -> Self {
let Update {
name, slug, units, ..
name,
slug,
units,
archived,
..
} = update;
Self {
name: name.map(Into::into),
slug: slug.map(Into::into),
units: units.map(Into::into),
archived,
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions services/cli/src/bencher/sub/project/report/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct List {
pub start_time: Option<DateTime>,
pub end_time: Option<DateTime>,
pub pagination: Pagination,
pub archived: bool,
pub backend: PubBackend,
}

Expand All @@ -40,6 +41,7 @@ impl TryFrom<CliReportList> for List {
start_time,
end_time,
pagination,
archived,
backend,
} = list;
Ok(Self {
Expand All @@ -49,6 +51,7 @@ impl TryFrom<CliReportList> for List {
start_time,
end_time,
pagination: pagination.into(),
archived,
backend: backend.try_into()?,
})
}
Expand Down Expand Up @@ -80,13 +83,15 @@ impl From<List> for JsonReportQuery {
testbed,
start_time,
end_time,
archived,
..
} = list;
Self {
branch,
testbed,
start_time,
end_time,
archived: archived.then_some(archived),
}
}
}
Expand All @@ -113,6 +118,10 @@ impl SubCmd for List {
client = client.end_time(end_time);
}

if let Some(archived) = json_report_query.archived {
client = client.archived(archived);
}

if let Some(sort) = self.pagination.sort {
client = client.sort(sort);
}
Expand Down
Loading

0 comments on commit a034224

Please sign in to comment.