Skip to content

Commit

Permalink
Fix: Return only the latest ticket for each ticket group
Browse files Browse the repository at this point in the history
  • Loading branch information
aliraza556 committed Feb 18, 2025
1 parent 32db907 commit 22a2239
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions handlers/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,8 @@ func (oh *featureHandler) GetQuickTickets(w http.ResponseWriter, r *http.Request
Unphased: make([]db.QuickTicketItem, 0),
}

latestTickets := make(map[string]db.QuickTicketItem)

for _, ticket := range tickets {
var phaseID *string
if ticket.PhaseUUID != "" {
Expand All @@ -992,8 +994,14 @@ func (oh *featureHandler) GetQuickTickets(w http.ResponseWriter, r *http.Request
PhaseID: phaseID,
}

if ticket.PhaseUUID != "" {
response.Phases[ticket.PhaseUUID] = append(response.Phases[ticket.PhaseUUID], item)
if existingItem, exists := latestTickets[ticket.TicketGroup.String()]; !exists || ticket.UUID.String() > existingItem.TicketUUID.String() {
latestTickets[ticket.TicketGroup.String()] = item
}
}

for _, item := range latestTickets {
if item.PhaseID != nil {
response.Phases[*item.PhaseID] = append(response.Phases[*item.PhaseID], item)
} else {
response.Unphased = append(response.Unphased, item)
}
Expand Down

0 comments on commit 22a2239

Please sign in to comment.