Skip to content

Commit f8f2056

Browse files
committed
Rename TeamApiClient to TeamClient
1 parent 03b6bf8 commit f8f2056

17 files changed

+85
-101
lines changed

src/actions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
77
use tera::{Context, Tera};
88

99
use crate::github::{self, GithubClient, Repository};
10-
use crate::team_data::TeamApiClient;
10+
use crate::team_data::TeamClient;
1111

1212
#[async_trait]
1313
pub trait Action {
@@ -107,7 +107,7 @@ impl<'a> Action for Step<'a> {
107107
async fn call(&self) -> anyhow::Result<String> {
108108
let mut gh = GithubClient::new_from_env();
109109
gh.set_retry_rate_limit(true);
110-
let team_api = TeamApiClient::new_from_env();
110+
let team_api = TeamClient::new_from_env();
111111

112112
let mut context = Context::new();
113113
let mut results = HashMap::new();

src/bin/project_goals.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clap::Parser;
2-
use triagebot::team_data::TeamApiClient;
2+
use triagebot::team_data::TeamClient;
33
use triagebot::zulip::client::ZulipClient;
44
use triagebot::{github::GithubClient, handlers::project_goals};
55

@@ -25,7 +25,7 @@ async fn main() -> anyhow::Result<()> {
2525
let opt = Opt::parse();
2626
let gh = GithubClient::new_from_env();
2727
let zulip = ZulipClient::new_from_env();
28-
let team_api = TeamApiClient::new_from_env();
28+
let team_api = TeamClient::new_from_env();
2929
project_goals::ping_project_goals_owners(
3030
&gh,
3131
&zulip,

src/github.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::team_data::TeamApiClient;
1+
use crate::team_data::TeamClient;
22
use anyhow::{anyhow, Context};
33
use async_trait::async_trait;
44
use bytes::Bytes;
@@ -241,7 +241,7 @@ impl User {
241241
.await
242242
}
243243

244-
pub async fn is_team_member<'a>(&'a self, client: &'a TeamApiClient) -> anyhow::Result<bool> {
244+
pub async fn is_team_member<'a>(&'a self, client: &'a TeamClient) -> anyhow::Result<bool> {
245245
log::trace!("Getting team membership for {:?}", self.login);
246246
let permission = client.teams().await?;
247247
let map = permission.teams;
@@ -2014,7 +2014,7 @@ impl<'q> IssuesQuery for Query<'q> {
20142014
include_fcp_details: bool,
20152015
include_mcp_details: bool,
20162016
gh_client: &'a GithubClient,
2017-
team_api_client: &'a TeamApiClient,
2017+
team_client: &'a TeamClient,
20182018
) -> anyhow::Result<Vec<crate::actions::IssueDecorator>> {
20192019
let issues = repo
20202020
.get_issues(&gh_client, self)
@@ -2030,7 +2030,7 @@ impl<'q> IssuesQuery for Query<'q> {
20302030
};
20312031

20322032
let zulip_map = if include_fcp_details {
2033-
Some(team_api_client.zulip_map().await?)
2033+
Some(team_client.zulip_map().await?)
20342034
} else {
20352035
None
20362036
};
@@ -2841,7 +2841,7 @@ pub trait IssuesQuery {
28412841
include_fcp_details: bool,
28422842
include_mcp_details: bool,
28432843
gh_client: &'a GithubClient,
2844-
team_api_client: &'a TeamApiClient,
2844+
team_client: &'a TeamClient,
28452845
) -> anyhow::Result<Vec<crate::actions::IssueDecorator>>;
28462846
}
28472847

@@ -2854,7 +2854,7 @@ impl IssuesQuery for LeastRecentlyReviewedPullRequests {
28542854
_include_fcp_details: bool,
28552855
_include_mcp_details: bool,
28562856
client: &'a GithubClient,
2857-
_team_api_client: &'a TeamApiClient,
2857+
_team_client: &'a TeamClient,
28582858
) -> anyhow::Result<Vec<crate::actions::IssueDecorator>> {
28592859
use cynic::QueryBuilder;
28602860
use github_graphql::queries;
@@ -3073,7 +3073,7 @@ impl IssuesQuery for DesignMeetings {
30733073
_include_fcp_details: bool,
30743074
_include_mcp_details: bool,
30753075
client: &'a GithubClient,
3076-
_team_api_client: &'a TeamApiClient,
3076+
_team_client: &'a TeamClient,
30773077
) -> anyhow::Result<Vec<crate::actions::IssueDecorator>> {
30783078
use github_graphql::project_items::ProjectV2ItemContent;
30793079

src/handlers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::config::{self, Config, ConfigurationError};
22
use crate::github::{Event, GithubClient, IssueCommentAction, IssuesAction, IssuesEvent};
33
use crate::handlers::pr_tracking::ReviewerWorkqueue;
4-
use crate::team_data::TeamApiClient;
4+
use crate::team_data::TeamClient;
55
use crate::zulip::client::ZulipClient;
66
use octocrab::Octocrab;
77
use parser::command::{assign::AssignCommand, Command, Input};
@@ -375,7 +375,7 @@ command_handlers! {
375375
pub struct Context {
376376
pub github: GithubClient,
377377
pub zulip: ZulipClient,
378-
pub team_api: TeamApiClient,
378+
pub team: TeamClient,
379379
pub db: crate::db::ClientPool,
380380
pub username: String,
381381
pub octocrab: Octocrab,

src/handlers/assign.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ async fn determine_assignee(
331331
diff: &[FileDiff],
332332
) -> anyhow::Result<(Option<ReviewerSelection>, bool)> {
333333
let mut db_client = ctx.db.get().await;
334-
let teams = &ctx.team_api.teams().await?;
334+
let teams = &ctx.team.teams().await?;
335335
if let Some(name) = assign_command {
336336
// User included `r?` in the opening PR body.
337337
match find_reviewer_from_names(
@@ -510,12 +510,11 @@ pub(super) async fn handle_command(
510510
event: &Event,
511511
cmd: AssignCommand,
512512
) -> anyhow::Result<()> {
513-
let is_team_member =
514-
if let Err(_) | Ok(false) = event.user().is_team_member(&ctx.team_api).await {
515-
false
516-
} else {
517-
true
518-
};
513+
let is_team_member = if let Err(_) | Ok(false) = event.user().is_team_member(&ctx.team).await {
514+
false
515+
} else {
516+
true
517+
};
519518

520519
// Don't handle commands in comments from the bot. Some of the comments it
521520
// posts contain commands to instruct the user, not things that the bot
@@ -545,7 +544,7 @@ pub(super) async fn handle_command(
545544
return Ok(());
546545
}
547546

548-
let teams = ctx.team_api.teams().await?;
547+
let teams = ctx.team.teams().await?;
549548

550549
let assignee = match cmd {
551550
AssignCommand::Claim => event.user().login.clone(),

src/handlers/close.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub(super) async fn handle_command(
1212
let issue = event.issue().unwrap();
1313
let is_team_member = event
1414
.user()
15-
.is_team_member(&ctx.team_api)
15+
.is_team_member(&ctx.team)
1616
.await
1717
.unwrap_or(false);
1818
if !is_team_member {

src/handlers/major_change.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ pub(super) async fn handle_command(
247247

248248
let is_team_member = event
249249
.user()
250-
.is_team_member(&ctx.team_api)
250+
.is_team_member(&ctx.team)
251251
.await
252252
.ok()
253253
.unwrap_or(false);

src/handlers/nominate.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ pub(super) async fn handle_command(
1414
event: &Event,
1515
cmd: NominateCommand,
1616
) -> anyhow::Result<()> {
17-
let is_team_member =
18-
if let Err(_) | Ok(false) = event.user().is_team_member(&ctx.team_api).await {
19-
false
20-
} else {
21-
true
22-
};
17+
let is_team_member = if let Err(_) | Ok(false) = event.user().is_team_member(&ctx.team).await {
18+
false
19+
} else {
20+
true
21+
};
2322

2423
if !is_team_member {
2524
let cmnt = ErrorComment::new(

src/handlers/notification.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ pub(super) async fn handle(ctx: &Context, event: &Event) -> anyhow::Result<()> {
6868
//
6969
// If the user intended to ping themselves, they can add the GitHub comment
7070
// via the Zulip interface.
71-
match ctx
72-
.team_api
73-
.get_gh_id_from_username(&event.user().login)
74-
.await
75-
{
71+
match ctx.team.get_gh_id_from_username(&event.user().login).await {
7672
Ok(Some(id)) => {
7773
users_notified.insert(id.try_into().unwrap());
7874
}
@@ -139,7 +135,7 @@ async fn id_from_user(
139135
//
140136
// We may also want to be able to categorize into these buckets
141137
// *after* the ping occurs and is initially processed.
142-
let team = match ctx.team_api.get_team_by_github_name(org, team).await {
138+
let team = match ctx.team.get_team_by_github_name(org, team).await {
143139
Ok(Some(team)) => team,
144140
Ok(None) => {
145141
// If the team is in rust-lang*, then this is probably an error (potentially user
@@ -174,7 +170,7 @@ async fn id_from_user(
174170
)))
175171
} else {
176172
let id = ctx
177-
.team_api
173+
.team
178174
.get_gh_id_from_username(login)
179175
.await
180176
.with_context(|| format!("failed to get user {} ID", login))?;

src/handlers/ping.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ pub(super) async fn handle_command(
1818
event: &Event,
1919
team_name: PingCommand,
2020
) -> anyhow::Result<()> {
21-
let is_team_member =
22-
if let Err(_) | Ok(false) = event.user().is_team_member(&ctx.team_api).await {
23-
false
24-
} else {
25-
true
26-
};
21+
let is_team_member = if let Err(_) | Ok(false) = event.user().is_team_member(&ctx.team).await {
22+
false
23+
} else {
24+
true
25+
};
2726

2827
if !is_team_member {
2928
let cmnt = ErrorComment::new(
@@ -49,7 +48,7 @@ pub(super) async fn handle_command(
4948
return Ok(());
5049
}
5150
};
52-
let team = ctx.team_api.get_team(&gh_team).await?;
51+
let team = ctx.team.get_team(&gh_team).await?;
5352
let team = match team {
5453
Some(team) => team,
5554
None => {

0 commit comments

Comments
 (0)