// StaleComments returns a slice of stale comments func (NagFlakeIssues) StaleComments(obj *mgh.MungeObject, comments []*github.IssueComment) []*github.IssueComment { // Remove all pings written before the last human actor comment return c.FilterComments(comments, c.And([]c.Matcher{ c.MungerNotificationName(flakeNagNotifyName), c.CreatedBefore(*c.LastComment(comments, c.HumanActor(), &time.Time{})), })) }
// Munge is the workhorse the will actually make updates to the PR func (NagFlakeIssues) Munge(obj *mgh.MungeObject) { if obj.IsPR() || !obj.HasLabel("kind/flake") { return } comments, err := obj.ListComments() if err != nil { glog.Error(err) return } // Use the pinger to notify assignees: // - Set time period based on configuration (at the top of this file) // - Mention list of assignees as an argument // - Start the ping timer after the last HumanActor comment // How often should we ping period := findTimePeriod(obj.Issue.Labels) // Who are we pinging who := mungerutil.GetIssueUsers(obj.Issue).Assignees.Mention().Join() // When does the pinger start startDate := c.LastComment(comments, c.HumanActor(), obj.Issue.CreatedAt) // Get a notification if it's time to ping. notif := pinger.SetTimePeriod(period).PingNotification( comments, who, startDate, ) if notif != nil { obj.WriteComment(notif.String()) } }