Skip to content

Commit

Permalink
Only mention people under very specific circumstances
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Apr 2, 2024
1 parent 97baa0b commit 189ae3d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<FCPReviewerDetails>,
pub concerns: Vec<FCPConcernDetails>,
}
Expand Down
15 changes: 15 additions & 0 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Utc>,
#[serde(alias = "submitted_at")] // for pull request reviews
pub updated_at: chrono::DateTime<Utc>,
#[serde(default, rename = "state")]
pub pr_review_state: Option<PullRequestReviewState>,
Expand Down Expand Up @@ -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,
Expand All @@ -1764,6 +1778,7 @@ impl<'q> IssuesQuery for Query<'q> {
.as_deref()
.unwrap_or("<unknown>")
.to_string(),
should_mention,
pending_reviewers: fcp
.reviews
.iter()
Expand Down
2 changes: 1 addition & 1 deletion templates/_issues_rfcbot.tt
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down

0 comments on commit 189ae3d

Please sign in to comment.