2020-02-29 01:20:46 +01:00
|
|
|
package model
|
|
|
|
|
2020-02-29 14:17:34 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2020-03-04 21:57:16 +01:00
|
|
|
type Ticket map[string]interface{}
|
2020-02-29 14:17:34 +01:00
|
|
|
|
2020-03-01 13:21:10 +01:00
|
|
|
func RemoveDuplicateTickets(tickets []*Ticket, fileOnly bool) []*Ticket {
|
2020-02-29 14:17:34 +01:00
|
|
|
ticketMap := map[string]*Ticket{}
|
|
|
|
for _, t := range tickets {
|
2020-03-04 21:57:16 +01:00
|
|
|
filename, _ := (*t)["filename"].(string)
|
|
|
|
lineNo, _ := (*t)["lineNo"].(int)
|
2020-03-01 13:21:10 +01:00
|
|
|
if fileOnly {
|
2020-03-04 21:57:16 +01:00
|
|
|
ticketMap[filename] = t
|
2020-03-01 13:21:10 +01:00
|
|
|
} else {
|
2020-03-04 21:57:16 +01:00
|
|
|
ticketMap[fmt.Sprintf("%s:%d", filename, lineNo)] = t
|
2020-03-01 13:21:10 +01:00
|
|
|
}
|
2020-02-29 14:17:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cleanTickets := []*Ticket{}
|
|
|
|
for _, t := range ticketMap {
|
|
|
|
cleanTickets = append(cleanTickets, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cleanTickets
|
|
|
|
}
|