mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-15 09:25:56 +08:00
chore: update normalize funnel steps
Signed-off-by: Shivanshu Raj Shrivastava <shivanshu1333@gmail.com>
This commit is contained in:
parent
9a96817a88
commit
77cd490e48
@ -48,17 +48,28 @@ func ValidateFunnelSteps(steps []tracefunnel.FunnelStep) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NormalizeFunnelSteps normalizes step orders to be sequential
|
// NormalizeFunnelSteps normalizes step orders to be sequential starting from 1.
|
||||||
|
// Returns a new slice with normalized step orders, leaving the input slice unchanged.
|
||||||
func NormalizeFunnelSteps(steps []tracefunnel.FunnelStep) []tracefunnel.FunnelStep {
|
func NormalizeFunnelSteps(steps []tracefunnel.FunnelStep) []tracefunnel.FunnelStep {
|
||||||
sort.Slice(steps, func(i, j int) bool {
|
if len(steps) == 0 {
|
||||||
return steps[i].Order < steps[j].Order
|
return nil
|
||||||
})
|
|
||||||
|
|
||||||
for i := range steps {
|
|
||||||
steps[i].Order = int64(i + 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return steps
|
// Create a copy of the input slice
|
||||||
|
newSteps := make([]tracefunnel.FunnelStep, len(steps))
|
||||||
|
copy(newSteps, steps)
|
||||||
|
|
||||||
|
// Sort the copy
|
||||||
|
sort.Slice(newSteps, func(i, j int) bool {
|
||||||
|
return newSteps[i].Order < newSteps[j].Order
|
||||||
|
})
|
||||||
|
|
||||||
|
// Update orders in the copy
|
||||||
|
for i := range newSteps {
|
||||||
|
newSteps[i].Order = int64(i + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return newSteps
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetClaims(r *http.Request) (*authtypes.Claims, error) {
|
func GetClaims(r *http.Request) (*authtypes.Claims, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user