diff --git a/src/actions.rs b/src/actions.rs index c010deb7..a230ce06 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_ping: bool, pub pending_reviewers: Vec, pub concerns: Vec, } diff --git a/src/github.rs b/src/github.rs index ce960d6b..a97d954d 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,17 @@ 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. + let should_ping = { + 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 +1777,7 @@ impl<'q> IssuesQuery for Query<'q> { .as_deref() .unwrap_or("") .to_string(), + should_ping, pending_reviewers: fcp .reviews .iter() diff --git a/templates/_issues_rfcbot.tt b/templates/_issues_rfcbot.tt index dce2d594..e22cb88d 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_ping %}{% 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}}