diff options
author | Özgür Kesim <oec@codeblau.de> | 2023-12-28 17:03:33 +0100 |
---|---|---|
committer | Özgür Kesim <oec@codeblau.de> | 2023-12-28 17:03:33 +0100 |
commit | 2f6c7f2a7d2cef0cb8956217864b4e664a784bef (patch) | |
tree | 428f24e817ad327e5afb35f314edd7b66d60f01d /issues.go | |
parent | ba0d00988101156e7daeb33923220dd0e82ac761 (diff) |
add information about assignment status
Diffstat (limited to 'issues.go')
-rw-r--r-- | issues.go | 41 |
1 files changed, 38 insertions, 3 deletions
@@ -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 } |