Skip to content

Commit 1632c08

Browse files
committed
chore(ENT-923): add priority comparison methods
1 parent 7e0a400 commit 1632c08

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pkg/models/priority.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,30 @@ const (
55
PriorityImportant string = "IMPORTANT"
66
PriorityInformational string = "INFORMATIONAL"
77
)
8+
9+
var priorityToInt = map[string]int{
10+
PriorityUrgent: 0,
11+
PriorityImportant: 1,
12+
PriorityInformational: 2,
13+
}
14+
15+
func ComparePriority(priority1, priority2 string) int {
16+
val1, ok1 := priorityToInt[priority1]
17+
val2, ok2 := priorityToInt[priority2]
18+
19+
if !ok1 && !ok2 {
20+
return 0
21+
} else if !ok1 {
22+
return -1
23+
} else if !ok2 {
24+
return 1
25+
}
26+
27+
if val1 < val2 {
28+
return -1
29+
} else if val1 > val2 {
30+
return 1
31+
} else {
32+
return 0
33+
}
34+
}

0 commit comments

Comments
 (0)