campaigner/model/ticket.go

26 lines
485 B
Go
Raw Normal View History

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"`
LineNo int `json:"line_no"`
2020-02-29 01:20:46 +01:00
Text string `json:"text"` // needed??
}
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
}