Skip to content

Commit 15905b2

Browse files
committed
chore - add missing unknown priority
1 parent 6f34d69 commit 15905b2

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

pkg/models/priority.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,29 @@ const (
44
PriorityUrgent string = "URGENT"
55
PriorityImportant string = "IMPORTANT"
66
PriorityInformational string = "INFORMATIONAL"
7+
PriorityUnknown string = "UNKNOWN"
78
)
89

910
var priorityToInt = map[string]int{
10-
PriorityInformational: 0,
11-
PriorityImportant: 1,
12-
PriorityUrgent: 2,
11+
PriorityUnknown: 0,
12+
PriorityInformational: 1,
13+
PriorityImportant: 2,
14+
PriorityUrgent: 3,
1315
}
1416

1517
func ComparePriority(priority1, priority2 string) int {
1618
val1, ok1 := priorityToInt[priority1]
1719
val2, ok2 := priorityToInt[priority2]
1820

21+
// If priority1 is NONE and priority2 is not in the map, treat them as equal
22+
if priority1 == PriorityUnknown && !ok2 {
23+
return 0
24+
}
25+
// If priority2 is NONE and priority1 is not in the map, treat them as equal
26+
if priority2 == PriorityUnknown && !ok1 {
27+
return 0
28+
}
29+
1930
if !ok1 && !ok2 {
2031
return 0
2132
} else if !ok1 {

pkg/models/priority_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ func TestComparePriority(t *testing.T) {
2020
{"INFORMATIONAL", "INFORMATIONAL", 0},
2121
{"IMPORTANT", "IMPORTANT", 0},
2222
{"URGENT", "URGENT", 0},
23+
{"NONE", "INVALID", 0},
24+
{"NONE", "UNKNOWN", 0},
25+
{"UNKNOWN", "", 0},
26+
{"", "UNKNOWN", 0},
2327
}
2428

2529
for _, test := range tests {

0 commit comments

Comments
 (0)