Skip to content

Commit

Permalink
fix slice error when fetching network metrics (highlight#7227)
Browse files Browse the repository at this point in the history
## Summary

Fixes runtime error
https://app.highlight.io/1/errors/h2yfoNmOw44yHVUc1uzdeDCFba8Y/instances/226248307

## How did you test this change?

Validating that the error does not happen when locally loading a network
request in dev tools.

## Are there any deployment considerations?

No

## Does this work require review from our design team?

No
  • Loading branch information
Vadman97 authored Dec 1, 2023
1 parent f9960c9 commit 6297549
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions backend/private-graph/graph/schema.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7130,10 +7130,12 @@ func (r *queryResolver) NetworkHistogram(ctx context.Context, projectID int, par
Count: int(count),
})
}
sort.Slice(result.Buckets, func(i, j int) bool {
return result.Buckets[i].Count > result.Buckets[j].Count
})
result.Buckets = result.Buckets[0:lo.Min([]int{30, len(result.Buckets) - 1})]
if len(result.Buckets) > 0 {
sort.Slice(result.Buckets, func(i, j int) bool {
return result.Buckets[i].Count > result.Buckets[j].Count
})
result.Buckets = result.Buckets[0:lo.Min([]int{30, len(result.Buckets) - 1})]
}

return result, nil
}
Expand Down

0 comments on commit 6297549

Please sign in to comment.