Skip to content

Commit 189ae3d

Browse files
committed
Only mention people under very specific circumstances
1 parent 97baa0b commit 189ae3d

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/actions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub struct FCPDetails {
7474
pub initiating_comment_html_url: String,
7575
pub initiating_comment_content: String,
7676
pub disposition: String,
77+
pub should_mention: bool,
7778
pub pending_reviewers: Vec<FCPReviewerDetails>,
7879
pub concerns: Vec<FCPConcernDetails>,
7980
}

src/github.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ pub struct Comment {
361361
pub html_url: String,
362362
pub user: User,
363363
#[serde(alias = "submitted_at")] // for pull request reviews
364+
pub created_at: chrono::DateTime<Utc>,
365+
#[serde(alias = "submitted_at")] // for pull request reviews
364366
pub updated_at: chrono::DateTime<Utc>,
365367
#[serde(default, rename = "state")]
366368
pub pr_review_state: Option<PullRequestReviewState>,
@@ -1753,6 +1755,18 @@ impl<'q> IssuesQuery for Query<'q> {
17531755
.get_comment(&client, fk_initiating_comment.try_into()?)
17541756
.await?;
17551757

1758+
// To avoid constant (and counter-productive) pings we will only ping when
1759+
// - we are 2 weeks into the FCP
1760+
// - or when there are no concerns and we are at least 4 weeks into the FCP.
1761+
//
1762+
// FIXME: This should get T-compiler approval before being enabled by default
1763+
let should_mention = std::env::var("TRIAGEBOT_COMPILER_MENTION").is_ok() && {
1764+
let now = chrono::offset::Utc::now();
1765+
let time_diff = now - init_comment.created_at;
1766+
time_diff.num_weeks() == 2
1767+
|| (time_diff.num_weeks() >= 4 && fcp.concerns.is_empty())
1768+
};
1769+
17561770
Some(crate::actions::FCPDetails {
17571771
bot_tracking_comment_html_url,
17581772
bot_tracking_comment_content,
@@ -1764,6 +1778,7 @@ impl<'q> IssuesQuery for Query<'q> {
17641778
.as_deref()
17651779
.unwrap_or("<unknown>")
17661780
.to_string(),
1781+
should_mention,
17671782
pending_reviewers: fcp
17681783
.reviews
17691784
.iter()

templates/_issues_rfcbot.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{%- for issue in issues %}
55
{%- if issue.fcp_details is object %}
66
{{indent}}- {{issue.fcp_details.disposition}}: [{{issue.title}} ({{issue.repo_name}}#{{issue.number}})]({{issue.fcp_details.bot_tracking_comment_html_url}})
7-
{{indent}}{{indent}}-{% for reviewer in issue.fcp_details.pending_reviewers %} @**|{{reviewer.zulip_id}}**{%else%} no pending checkboxs{% endfor %}
7+
{{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 %}
88
{{indent}}{{indent}}-{% for concern in issue.fcp_details.concerns %} [{{concern.name}} (by {{concern.reviewer_login}})]({{concern.concern_url}}){%else%} no pending concerns{% endfor -%}
99
{% else %}
1010
{{indent}}- "{{issue.title}}" {{issue.repo_name}}#{{issue.number}}

0 commit comments

Comments
 (0)