2020-02-29 01:20:46 +01:00
|
|
|
package model
|
|
|
|
|
2020-02-29 14:17:34 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2020-02-29 01:20:46 +01:00
|
|
|
type Ticket struct {
|
|
|
|
Filename string `json:"filename"`
|
2020-02-29 13:00:40 +01:00
|
|
|
LineNo int `json:"line_no"`
|
2020-02-29 14:18:27 +01:00
|
|
|
Text string `json:"text"`
|
2020-02-29 01:20:46 +01:00
|
|
|
}
|
2020-02-29 14:17:34 +01:00
|
|
|
|
|
|
|
func RemoveDuplicateTickets(tickets []*Ticket) []*Ticket {
|
|
|
|
ticketMap := map[string]*Ticket{}
|
|
|
|
for _, t := range tickets {
|
|
|
|
ticketMap[fmt.Sprintf("%s:%d", t.Filename, t.LineNo)] = t
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanTickets := []*Ticket{}
|
|
|
|
for _, t := range ticketMap {
|
|
|
|
cleanTickets = append(cleanTickets, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cleanTickets
|
|
|
|
}
|