From a60b3ddf936e3ffbb2428a79b0c8d54ab3bb3ffe Mon Sep 17 00:00:00 2001 From: Mauro Stettler Date: Fri, 31 May 2024 08:30:51 +0200 Subject: [PATCH 1/9] debug issue busyness calculation Signed-off-by: Mauro Stettler --- pkg/icassigner/busyness/busyness.go | 50 +++++++++++++++++++---------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/pkg/icassigner/busyness/busyness.go b/pkg/icassigner/busyness/busyness.go index 3a2d72a..90bf1b5 100644 --- a/pkg/icassigner/busyness/busyness.go +++ b/pkg/icassigner/busyness/busyness.go @@ -19,6 +19,7 @@ package busyness import ( "context" "fmt" + "log" "slices" "strings" "time" @@ -55,6 +56,8 @@ type busynessClient interface { // CalculateBusynessForTeam calculates busyness of all members and returns a BusynessReport for them func CalculateBusynessForTeam(ctx context.Context, now time.Time, githubClient *github.Client, ignorableLabels []string, members []string) (Report, error) { + log.Printf("Calculating issue busyness for team members: %s\n", strings.Join(members, ", ")) + bA, err := newGithubBusynessClient(githubClient, ignorableLabels) if err != nil { return Report{}, fmt.Errorf("unable to create github busyness client, due %w", err) @@ -140,15 +143,8 @@ func newGithubBusynessClient(githubClient *github.Client, ignorableLabels []stri // If there are labels to be ignored, all issues with that label are ignored from the busyness calculation func (b *githubBusynessClient) getBusyness(ctx context.Context, since time.Time, member string) int { // check if one of the labels is contained by the labels to ignore - containsLabelsToIgnore := func(labels []github.Label) bool { - for _, l := range labels { - _, tobeIgnored := b.labelsToIgnore[*l.Name] - if tobeIgnored { - return true - } - } - return false - } + + log.Printf("Listing issues of member %s since %s\n", member, since.String()) issues, err := b.listByAssigneeFunc(ctx, since, member, 20) if err != nil { @@ -158,27 +154,47 @@ func (b *githubBusynessClient) getBusyness(ctx context.Context, since time.Time, // count relevant issues busyness := 0 for _, i := range issues { - // ignore everything without any state - if i.State == nil { - continue - } - - switch *i.State { + switch i.GetState() { case "open": // check for labels to ignore, e.g. `stale` and ignore issue in this case - if containsLabelsToIgnore(i.Labels) { + if b.containsLabelsToIgnore(i.Labels) { + log.Printf("Ignoring open issue because it contains labels to ignore (%s): %s\n", labelsToString(i.Labels), i.GetTitle()) continue } // increase busyness count otherwise + log.Printf("Issue increases busyiness because it is still open: %s\n", i.GetTitle()) busyness++ case "closed": // if the issue got closed since our time to check - if since.Before(*i.ClosedAt) { + if since.Before(i.GetClosedAt()) { + log.Printf("Issue increases busyiness because it has been closed at %s which is after %s: %s\n", i.GetClosedAt().String(), since.String(), i.GetTitle()) busyness++ + } else { + log.Printf("Issue doesn't increase busyiness because it has been closed at %s which is before %s: %s\n", i.GetClosedAt().String(), since.String(), i.GetTitle()) } + default: + log.Printf("Issue doesn't increase busyiness because it has an unknown state (%s): %s\n", i.GetState(), i.GetTitle()) } } return busyness } + +func (b *githubBusynessClient) containsLabelsToIgnore(labels []github.Label) bool { + for _, l := range labels { + _, tobeIgnored := b.labelsToIgnore[l.GetName()] + if tobeIgnored { + return true + } + } + return false +} + +func labelsToString(labels []github.Label) string { + labelNames := make([]string, len(labels)) + for idx, l := range labels { + labelNames[idx] = l.GetName() + } + return strings.Join(labelNames, ", ") +} From 1bc05170ae4fc118d8bbc8ed629338c800526c07 Mon Sep 17 00:00:00 2001 From: Mauro Stettler Date: Fri, 31 May 2024 08:31:32 +0200 Subject: [PATCH 2/9] bump version Signed-off-by: Mauro Stettler --- ic-assignment/action.yml | 2 +- regex-labeler/action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ic-assignment/action.yml b/ic-assignment/action.yml index 329557a..0adcdd5 100644 --- a/ic-assignment/action.yml +++ b/ic-assignment/action.yml @@ -21,4 +21,4 @@ outputs: description: "The output property of the assigned person. If output property is empty, name is used instead" runs: using: "docker" - image: "docker://ghcr.io/grafana/issue-team-scheduler-ic-assignment:v0.12" + image: "docker://ghcr.io/grafana/issue-team-scheduler-ic-assignment:v0.13" diff --git a/regex-labeler/action.yml b/regex-labeler/action.yml index f613738..0ab1056 100644 --- a/regex-labeler/action.yml +++ b/regex-labeler/action.yml @@ -9,4 +9,4 @@ inputs: description: "GitHub token to use for API calls" runs: using: "docker" - image: "docker://ghcr.io/grafana/issue-team-scheduler-regex-labeler:v0.12" + image: "docker://ghcr.io/grafana/issue-team-scheduler-regex-labeler:v0.13" From 33c4b4603d2810964b88432342756793dd87d051 Mon Sep 17 00:00:00 2001 From: Mauro Stettler Date: Fri, 31 May 2024 08:32:45 +0200 Subject: [PATCH 3/9] wording Signed-off-by: Mauro Stettler --- pkg/icassigner/busyness/busyness.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/icassigner/busyness/busyness.go b/pkg/icassigner/busyness/busyness.go index 90bf1b5..81012b2 100644 --- a/pkg/icassigner/busyness/busyness.go +++ b/pkg/icassigner/busyness/busyness.go @@ -56,7 +56,7 @@ type busynessClient interface { // CalculateBusynessForTeam calculates busyness of all members and returns a BusynessReport for them func CalculateBusynessForTeam(ctx context.Context, now time.Time, githubClient *github.Client, ignorableLabels []string, members []string) (Report, error) { - log.Printf("Calculating issue busyness for team members: %s\n", strings.Join(members, ", ")) + log.Printf("Calculating busyness for team members: %s\n", strings.Join(members, ", ")) bA, err := newGithubBusynessClient(githubClient, ignorableLabels) if err != nil { From 772210ac4ab65d199c9aab8e096272a157ad6a48 Mon Sep 17 00:00:00 2001 From: Mauro Stettler Date: Fri, 31 May 2024 08:34:25 +0200 Subject: [PATCH 4/9] wording Signed-off-by: Mauro Stettler --- pkg/icassigner/busyness/busyness.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/icassigner/busyness/busyness.go b/pkg/icassigner/busyness/busyness.go index 81012b2..36e278a 100644 --- a/pkg/icassigner/busyness/busyness.go +++ b/pkg/icassigner/busyness/busyness.go @@ -144,7 +144,7 @@ func newGithubBusynessClient(githubClient *github.Client, ignorableLabels []stri func (b *githubBusynessClient) getBusyness(ctx context.Context, since time.Time, member string) int { // check if one of the labels is contained by the labels to ignore - log.Printf("Listing issues of member %s since %s\n", member, since.String()) + log.Printf("Calculating busyness of member %s based on their issues since %s\n", member, since.String()) issues, err := b.listByAssigneeFunc(ctx, since, member, 20) if err != nil { @@ -158,7 +158,7 @@ func (b *githubBusynessClient) getBusyness(ctx context.Context, since time.Time, case "open": // check for labels to ignore, e.g. `stale` and ignore issue in this case if b.containsLabelsToIgnore(i.Labels) { - log.Printf("Ignoring open issue because it contains labels to ignore (%s): %s\n", labelsToString(i.Labels), i.GetTitle()) + log.Printf("%s: Ignoring open issue because it contains labels to ignore (%s): %s\n", member, labelsToString(i.Labels), i.GetTitle()) continue } @@ -168,13 +168,13 @@ func (b *githubBusynessClient) getBusyness(ctx context.Context, since time.Time, case "closed": // if the issue got closed since our time to check if since.Before(i.GetClosedAt()) { - log.Printf("Issue increases busyiness because it has been closed at %s which is after %s: %s\n", i.GetClosedAt().String(), since.String(), i.GetTitle()) + log.Printf("%s: Issue increases busyiness because it has been closed at %s which is after %s: %s\n", member, i.GetClosedAt().String(), since.String(), i.GetTitle()) busyness++ } else { - log.Printf("Issue doesn't increase busyiness because it has been closed at %s which is before %s: %s\n", i.GetClosedAt().String(), since.String(), i.GetTitle()) + log.Printf("%s: Issue doesn't increase busyiness because it has been closed at %s which is before %s: %s\n", member, i.GetClosedAt().String(), since.String(), i.GetTitle()) } default: - log.Printf("Issue doesn't increase busyiness because it has an unknown state (%s): %s\n", i.GetState(), i.GetTitle()) + log.Printf("%s: Issue doesn't increase busyiness because it has an unknown state (%s): %s\n", member, i.GetState(), i.GetTitle()) } } From cf8bcbf4ef5bbd03849d4fccc88ae26affaa2ec1 Mon Sep 17 00:00:00 2001 From: Mauro Stettler Date: Fri, 31 May 2024 08:34:47 +0200 Subject: [PATCH 5/9] prefix with name Signed-off-by: Mauro Stettler --- pkg/icassigner/busyness/busyness.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/icassigner/busyness/busyness.go b/pkg/icassigner/busyness/busyness.go index 36e278a..489fcc5 100644 --- a/pkg/icassigner/busyness/busyness.go +++ b/pkg/icassigner/busyness/busyness.go @@ -163,7 +163,7 @@ func (b *githubBusynessClient) getBusyness(ctx context.Context, since time.Time, } // increase busyness count otherwise - log.Printf("Issue increases busyiness because it is still open: %s\n", i.GetTitle()) + log.Printf("%s: Issue increases busyiness because it is still open: %s\n", member, i.GetTitle()) busyness++ case "closed": // if the issue got closed since our time to check From b10b5082ccd950daf654798e47dc700a97ec3a3f Mon Sep 17 00:00:00 2001 From: Mauro Stettler Date: Fri, 31 May 2024 15:14:40 +0200 Subject: [PATCH 6/9] spelling Co-authored-by: Dimitar Dimitrov --- pkg/icassigner/busyness/busyness.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/icassigner/busyness/busyness.go b/pkg/icassigner/busyness/busyness.go index 489fcc5..8e95500 100644 --- a/pkg/icassigner/busyness/busyness.go +++ b/pkg/icassigner/busyness/busyness.go @@ -168,7 +168,7 @@ func (b *githubBusynessClient) getBusyness(ctx context.Context, since time.Time, case "closed": // if the issue got closed since our time to check if since.Before(i.GetClosedAt()) { - log.Printf("%s: Issue increases busyiness because it has been closed at %s which is after %s: %s\n", member, i.GetClosedAt().String(), since.String(), i.GetTitle()) + log.Printf("%s: Issue increases busyness because it has been closed at %s which is after %s: %s\n", member, i.GetClosedAt().String(), since.String(), i.GetTitle()) busyness++ } else { log.Printf("%s: Issue doesn't increase busyiness because it has been closed at %s which is before %s: %s\n", member, i.GetClosedAt().String(), since.String(), i.GetTitle()) From b6d332eb8d372360dbfadb26702869223cdc3283 Mon Sep 17 00:00:00 2001 From: Mauro Stettler Date: Fri, 31 May 2024 15:14:47 +0200 Subject: [PATCH 7/9] spelling Co-authored-by: Dimitar Dimitrov --- pkg/icassigner/busyness/busyness.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/icassigner/busyness/busyness.go b/pkg/icassigner/busyness/busyness.go index 8e95500..78bfe09 100644 --- a/pkg/icassigner/busyness/busyness.go +++ b/pkg/icassigner/busyness/busyness.go @@ -163,7 +163,7 @@ func (b *githubBusynessClient) getBusyness(ctx context.Context, since time.Time, } // increase busyness count otherwise - log.Printf("%s: Issue increases busyiness because it is still open: %s\n", member, i.GetTitle()) + log.Printf("%s: Issue increases busyness because it is still open: %s\n", member, i.GetTitle()) busyness++ case "closed": // if the issue got closed since our time to check From e0a112abead7e21f04b7a6522015d9e705cfa033 Mon Sep 17 00:00:00 2001 From: Mauro Stettler Date: Fri, 31 May 2024 15:14:52 +0200 Subject: [PATCH 8/9] spelling Co-authored-by: Dimitar Dimitrov --- pkg/icassigner/busyness/busyness.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/icassigner/busyness/busyness.go b/pkg/icassigner/busyness/busyness.go index 78bfe09..8cb24f5 100644 --- a/pkg/icassigner/busyness/busyness.go +++ b/pkg/icassigner/busyness/busyness.go @@ -174,7 +174,7 @@ func (b *githubBusynessClient) getBusyness(ctx context.Context, since time.Time, log.Printf("%s: Issue doesn't increase busyiness because it has been closed at %s which is before %s: %s\n", member, i.GetClosedAt().String(), since.String(), i.GetTitle()) } default: - log.Printf("%s: Issue doesn't increase busyiness because it has an unknown state (%s): %s\n", member, i.GetState(), i.GetTitle()) + log.Printf("%s: Issue doesn't increase busyness because it has an unknown state (%s): %s\n", member, i.GetState(), i.GetTitle()) } } From 0874cb68e75bf12c1b4e677e15a369945985e920 Mon Sep 17 00:00:00 2001 From: Mauro Stettler Date: Fri, 31 May 2024 15:14:57 +0200 Subject: [PATCH 9/9] spelling Co-authored-by: Dimitar Dimitrov --- pkg/icassigner/busyness/busyness.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/icassigner/busyness/busyness.go b/pkg/icassigner/busyness/busyness.go index 8cb24f5..70100a2 100644 --- a/pkg/icassigner/busyness/busyness.go +++ b/pkg/icassigner/busyness/busyness.go @@ -171,7 +171,7 @@ func (b *githubBusynessClient) getBusyness(ctx context.Context, since time.Time, log.Printf("%s: Issue increases busyness because it has been closed at %s which is after %s: %s\n", member, i.GetClosedAt().String(), since.String(), i.GetTitle()) busyness++ } else { - log.Printf("%s: Issue doesn't increase busyiness because it has been closed at %s which is before %s: %s\n", member, i.GetClosedAt().String(), since.String(), i.GetTitle()) + log.Printf("%s: Issue doesn't increase busyness because it has been closed at %s which is before %s: %s\n", member, i.GetClosedAt().String(), since.String(), i.GetTitle()) } default: log.Printf("%s: Issue doesn't increase busyness because it has an unknown state (%s): %s\n", member, i.GetState(), i.GetTitle())