campaigner/model/ticket.go
2020-03-04 23:07:26 +01:00

31 lines
713 B
Go

package model
import (
"fmt"
)
type Ticket struct {
GithubLink string `json:"githubLink,omitempty"`
JiraLink string `json:"jiraLink,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
}
func RemoveDuplicateTickets(tickets []*Ticket, fileOnly bool) []*Ticket {
ticketMap := map[string]*Ticket{}
for _, t := range tickets {
filename, _ := t.Data["filename"].(string)
lineNo, _ := t.Data["lineNo"].(int)
if fileOnly {
ticketMap[filename] = t
} else {
ticketMap[fmt.Sprintf("%s:%d", filename, lineNo)] = t
}
}
cleanTickets := []*Ticket{}
for _, t := range ticketMap {
cleanTickets = append(cleanTickets, t)
}
return cleanTickets
}