Change ticket from struct to map
This commit is contained in:
parent
089a61bd41
commit
ae4b6e6620
2 changed files with 8 additions and 12 deletions
|
@ -104,9 +104,9 @@ func parseGrepLine(line string) (*model.Ticket, error) {
|
||||||
text := strings.Join(parts[2:], "")
|
text := strings.Join(parts[2:], "")
|
||||||
|
|
||||||
return &model.Ticket{
|
return &model.Ticket{
|
||||||
Filename: filename,
|
"filename": filename,
|
||||||
LineNo: lineNo,
|
"lineNo": lineNo,
|
||||||
Text: text,
|
"text": text,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,21 +4,17 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Ticket struct {
|
type Ticket map[string]interface{}
|
||||||
Filename string `json:"filename"`
|
|
||||||
LineNo int `json:"line_no"`
|
|
||||||
Text string `json:"text"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func RemoveDuplicateTickets(tickets []*Ticket, fileOnly bool) []*Ticket {
|
func RemoveDuplicateTickets(tickets []*Ticket, fileOnly bool) []*Ticket {
|
||||||
ticketMap := map[string]*Ticket{}
|
ticketMap := map[string]*Ticket{}
|
||||||
for _, t := range tickets {
|
for _, t := range tickets {
|
||||||
|
filename, _ := (*t)["filename"].(string)
|
||||||
|
lineNo, _ := (*t)["lineNo"].(int)
|
||||||
if fileOnly {
|
if fileOnly {
|
||||||
t.Text = ""
|
ticketMap[filename] = t
|
||||||
t.LineNo = 0
|
|
||||||
ticketMap[t.Filename] = t
|
|
||||||
} else {
|
} else {
|
||||||
ticketMap[fmt.Sprintf("%s:%d", t.Filename, t.LineNo)] = t
|
ticketMap[fmt.Sprintf("%s:%d", filename, lineNo)] = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue