From 2f6c7f2a7d2cef0cb8956217864b4e664a784bef Mon Sep 17 00:00:00 2001 From: Özgür Kesim Date: Thu, 28 Dec 2023 17:03:33 +0100 Subject: add information about assignment status --- issues.go | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'issues.go') diff --git a/issues.go b/issues.go index ce0f0c4..055b720 100644 --- a/issues.go +++ b/issues.go @@ -36,7 +36,7 @@ type Issue struct { Category KeyVal TargetVersion KeyVal `json:"target_version"` Reporter KeyVal - handler KeyVal + Handler KeyVal Status KeyVal Resolution KeyVal ViewState KeyVal `json:"view_state"` @@ -103,6 +103,15 @@ func (b ByCategory) Less(i, j int) bool { } func (b ByCategory) Swap(i, j int) { b[i], b[j] = b[j], b[i] } +type ByAssignment []Issue + +func (b ByAssignment) Len() int { return len(b) } +func (b ByAssignment) Less(i, j int) bool { + return strings.Compare(b[i].Handler.Name, b[j].Handler.Name) < 0 +} +func (b ByAssignment) Swap(i, j int) { b[i], b[j] = b[j], b[i] } + + type ById []Issue func (b ById) Len() int { return len(b) } @@ -117,6 +126,19 @@ func (b ByTarget) Less(i, j int) bool { } func (b ByTarget) Swap(i, j int) { b[i], b[j] = b[j], b[i] } +type ByHandlerAndId []Issue + +func (b ByHandlerAndId) Len() int { return len(b) } +func (b ByHandlerAndId) Less(i, j int) bool { + if (b[i].Handler.Name == "") == (b[j].Handler.Name == "") { + return b[i].Id < b[j].Id + } else if b[i].Handler.Name == "" { + return true + } + return false +} +func (b ByHandlerAndId) Swap(i, j int) { b[i], b[j] = b[j], b[i] } + func (i Issues) Tags() (tags []string) { var m = map[string]bool{} for _, issue := range i { @@ -131,6 +153,19 @@ func (i Issues) Tags() (tags []string) { return } +func (is Issues) Assigned(assigned bool) (n int) { + for _, i := range is { + if assigned == (i.Handler.Name != "") { + n += 1 + } + } + return n +} + +func (i *Issue) IsHandled() bool { + return i.Handler.Name != "" +} + func (i Issues) TargetVersions() (targets []string) { var m = map[string]bool{} for _, issue := range i { @@ -164,7 +199,7 @@ func (i Issues) ByCategory(cat string) (issues Issues) { issues = append(issues, issue) } } - sort.Sort(ById(issues)) + sort.Sort(sort.Reverse(ByHandlerAndId(issues))) return issues } @@ -175,6 +210,6 @@ func (i Issues) ByCategoryAndTarget(cat, tar string) (issues Issues) { issues = append(issues, is) } } - sort.Sort(ById(issues)) + sort.Sort(sort.Reverse(ByHandlerAndId(issues))) return } -- cgit v1.2.3