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 Mar 28, 2024
1 parent 97baa0b commit 09612bf
Show file tree
Hide file tree
Showing 3 changed files with 16 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_ping: bool,
pub pending_reviewers: Vec<FCPReviewerDetails>,
pub concerns: Vec<FCPConcernDetails>,
}
Expand Down
14 changes: 14 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,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,
Expand All @@ -1764,6 +1777,7 @@ impl<'q> IssuesQuery for Query<'q> {
.as_deref()
.unwrap_or("<unknown>")
.to_string(),
should_ping,
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_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}}
Expand Down

0 comments on commit 09612bf

Please sign in to comment.