Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ var (

maxRefresh = flag.Duration("max-refresh", 60*time.Minute, "Maximum time between collection runs")
minRefresh = flag.Duration("min-refresh", 60*time.Second, "Minimum time between collection runs")
memberRefresh = flag.Duration("membership-refresh", 24*time.Hour, "Minimum time between refreshing membership information")
)

const DefaultConfigPath = "/app/config/config.yaml"
Expand Down Expand Up @@ -107,7 +106,6 @@ func main() {
cfg := triage.Config{
Client: client,
Cache: c,
MemberRefresh: *memberRefresh,
}

if *reposOverride != "" {
Expand Down
7 changes: 3 additions & 4 deletions cmd/tester/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,9 @@ func main() {
}

cfg := triage.Config{
Client: client,
Cache: c,
MemberRefresh: 90 * 24 * time.Hour,
DebugNumber: *number,
Client: client,
Cache: c,
DebugNumber: *number,
}

if *reposOverride != "" {
Expand Down
7 changes: 0 additions & 7 deletions pkg/hubbub/hubbub.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ type Config struct {
Cache persist.Cacher // Cacher is a cache interface
Repos []string // Repos is the repositories to search

// Cache expiration times
MemberRefresh time.Duration

// MinSimilarity is how close two items need to be to each other to be called similar
MinSimilarity float64

Expand All @@ -47,9 +44,6 @@ type Engine struct {
cache persist.Cacher
client *github.Client

// How often to refresh organizational membership information
memberRefresh time.Duration

// Must be settable from config
MinSimilarity float64

Expand All @@ -70,7 +64,6 @@ func New(cfg Config) *Engine {
cache: cfg.Cache,
client: cfg.Client,

memberRefresh: cfg.MemberRefresh,
MaxClosedUpdateAge: cfg.MaxClosedUpdateAge,
seen: map[string]*Conversation{},
MinSimilarity: cfg.MinSimilarity,
Expand Down
4 changes: 2 additions & 2 deletions pkg/hubbub/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ type CommentLike interface {
String() string
}

func (h *Engine) IssueSummary(i *github.Issue, cs []*github.IssueComment, authorIsMember bool) *Conversation {
func (h *Engine) IssueSummary(i *github.Issue, cs []*github.IssueComment) *Conversation {
cl := []CommentLike{}
for _, c := range cs {
cl = append(cl, CommentLike(c))
}
co := h.conversation(i, cl, authorIsMember)
co := h.conversation(i, cl)
r := i.GetReactions()
co.ReactionsTotal += r.GetTotalCount()
for k, v := range reactions(r) {
Expand Down
8 changes: 7 additions & 1 deletion pkg/hubbub/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
// GitHubItem is an interface that matches both GitHub Issues and PullRequests
type GitHubItem interface {
GetAssignee() *github.User
GetAuthorAssociation() string
GetBody() string
GetComments() int
GetHTMLURL() string
Expand All @@ -29,7 +30,12 @@ type GitHubItem interface {
}

// conversation creates a conversation from an issue-like
func (h *Engine) conversation(i GitHubItem, cs []CommentLike, authorIsMember bool) *Conversation {
func (h *Engine) conversation(i GitHubItem, cs []CommentLike) *Conversation {
authorIsMember := false
if isMember(i.GetAuthorAssociation()) {
authorIsMember = true
}

co := &Conversation{
ID: i.GetNumber(),
URL: i.GetHTMLURL(),
Expand Down
63 changes: 0 additions & 63 deletions pkg/hubbub/orgs.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/hubbub/pull_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (h *Engine) PRSummary(pr *github.PullRequest, cs []*github.PullRequestComme
}
}

co := h.conversation(pr, cl, isMember(pr.GetAuthorAssociation()))
co := h.conversation(pr, cl)
co.Type = PullRequest

h.addEvents(co, timeline)
Expand Down
18 changes: 1 addition & 17 deletions pkg/hubbub/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,11 @@ func (h *Engine) SearchIssues(ctx context.Context, org string, project string, f
klog.V(1).Infof("Gathering raw data for %s/%s search %s - newer than %s", org, project, toYAML(fs), logu.STime(newerThan))
var wg sync.WaitGroup

var members map[string]bool
var open []*github.Issue
var closed []*github.Issue
var err error

age := time.Now()
orgCutoff := time.Now().Add(h.memberRefresh * -1)
if orgCutoff.After(newerThan) {
klog.V(1).Infof("Setting org cutoff to %s", newerThan)
orgCutoff = newerThan
}

wg.Add(1)
go func() {
defer wg.Done()
members, _, err = h.cachedOrgMembers(ctx, org, orgCutoff)
if err != nil {
klog.Errorf("members: %v", err)
return
}
}()

wg.Add(1)
go func() {
Expand Down Expand Up @@ -144,7 +128,7 @@ func (h *Engine) SearchIssues(ctx context.Context, org string, project string, f
}
}

co := h.IssueSummary(i, comments, members[i.User.GetLogin()])
co := h.IssueSummary(i, comments)
co.Labels = labels
h.seen[co.URL] = co

Expand Down
24 changes: 11 additions & 13 deletions pkg/triage/triage.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,26 @@ type Config struct {
Client *github.Client
Cache persist.Cacher
Repos []string
MemberRefresh time.Duration
// DebugNumber is useful when you want to debug why a single issue is or is-not appearing
DebugNumber int
}

type Party struct {
engine *hubbub.Engine
settings Settings
collections []Collection
cache persist.Cacher
rules map[string]Rule
reposOverride []string
debugNumber int
engine *hubbub.Engine
settings Settings
collections []Collection
cache persist.Cacher
rules map[string]Rule
reposOverride []string
debugNumber int
}

func New(cfg Config) *Party {
hc := hubbub.Config{
Client: cfg.Client,
Cache: cfg.Cache,
Repos: cfg.Repos,
DebugNumber: cfg.DebugNumber,
MemberRefresh: cfg.MemberRefresh,
Client: cfg.Client,
Cache: cfg.Cache,
Repos: cfg.Repos,
DebugNumber: cfg.DebugNumber,
}

klog.Infof("New hubbub with config: %+v", hc)
Expand Down