From 189ae3d9814ce55be2d0fac477ecbd773529969f Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 28 Mar 2024 22:25:48 +0100 Subject: [PATCH] Only mention people under very specific circumstances --- src/actions.rs | 1 + src/github.rs | 15 +++++++++++++++ templates/_issues_rfcbot.tt | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/actions.rs b/src/actions.rs index c010deb7..5cdfe86f 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -74,6 +74,7 @@ pub struct FCPDetails { pub initiating_comment_html_url: String, pub initiating_comment_content: String, pub disposition: String, + pub should_mention: bool, pub pending_reviewers: Vec, pub concerns: Vec, } diff --git a/src/github.rs b/src/github.rs index ce960d6b..274500bf 100644 --- a/src/github.rs +++ b/src/github.rs @@ -361,6 +361,8 @@ pub struct Comment { pub html_url: String, pub user: User, #[serde(alias = "submitted_at")] // for pull request reviews + pub created_at: chrono::DateTime, + #[serde(alias = "submitted_at")] // for pull request reviews pub updated_at: chrono::DateTime, #[serde(default, rename = "state")] pub pr_review_state: Option, @@ -1753,6 +1755,18 @@ impl<'q> IssuesQuery for Query<'q> { .get_comment(&client, fk_initiating_comment.try_into()?) .await?; + // To avoid constant (and counter-productive) pings we will only ping when + // - we are 2 weeks into the FCP + // - or when there are no concerns and we are at least 4 weeks into the FCP. + // + // FIXME: This should get T-compiler approval before being enabled by default + let should_mention = std::env::var("TRIAGEBOT_COMPILER_MENTION").is_ok() && { + let now = chrono::offset::Utc::now(); + let time_diff = now - init_comment.created_at; + time_diff.num_weeks() == 2 + || (time_diff.num_weeks() >= 4 && fcp.concerns.is_empty()) + }; + Some(crate::actions::FCPDetails { bot_tracking_comment_html_url, bot_tracking_comment_content, @@ -1764,6 +1778,7 @@ impl<'q> IssuesQuery for Query<'q> { .as_deref() .unwrap_or("") .to_string(), + should_mention, pending_reviewers: fcp .reviews .iter() diff --git a/templates/_issues_rfcbot.tt b/templates/_issues_rfcbot.tt index dce2d594..cdb117e4 100644 --- a/templates/_issues_rfcbot.tt +++ b/templates/_issues_rfcbot.tt @@ -4,7 +4,7 @@ {%- for issue in issues %} {%- if issue.fcp_details is object %} {{indent}}- {{issue.fcp_details.disposition}}: [{{issue.title}} ({{issue.repo_name}}#{{issue.number}})]({{issue.fcp_details.bot_tracking_comment_html_url}}) -{{indent}}{{indent}}-{% for reviewer in issue.fcp_details.pending_reviewers %} @**|{{reviewer.zulip_id}}**{%else%} no pending checkboxs{% endfor %} +{{indent}}{{indent}}-{% for reviewer in issue.fcp_details.pending_reviewers %} @{% if issue.fcp_details.should_mention %}{% else %}_{% endif %}**|{{reviewer.zulip_id}}**{%else%} no pending checkboxs{% endfor %} {{indent}}{{indent}}-{% for concern in issue.fcp_details.concerns %} [{{concern.name}} (by {{concern.reviewer_login}})]({{concern.concern_url}}){%else%} no pending concerns{% endfor -%} {% else %} {{indent}}- "{{issue.title}}" {{issue.repo_name}}#{{issue.number}}