mirror of
https://github.com/hashicorp/vault.git
synced 2025-12-16 15:01:13 +01:00
change ordering of activity log month data to sort by ascending order… (#15259)
* change ordering of activity log month data to sort by ascending order of timestamp * changelog * changelog
This commit is contained in:
parent
90f37a397b
commit
b6826e8830
3
changelog/15259.txt
Normal file
3
changelog/15259.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
```release-note:improvement
|
||||||
|
core/activity: Order month data in ascending order of timestamps
|
||||||
|
```
|
||||||
@ -1663,9 +1663,17 @@ func (a *ActivityLog) handleQuery(ctx context.Context, startTime, endTime time.T
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the months in the descending order of activity
|
// Sort the months in ascending order of timestamps
|
||||||
sort.Slice(months, func(i, j int) bool {
|
sort.Slice(months, func(i, j int) bool {
|
||||||
return months[i].Counts.Clients > months[j].Counts.Clients
|
firstTimestamp, errOne := time.Parse(time.RFC3339, months[i].Timestamp)
|
||||||
|
secondTimestamp, errTwo := time.Parse(time.RFC3339, months[j].Timestamp)
|
||||||
|
if errOne == nil && errTwo == nil {
|
||||||
|
return firstTimestamp.Before(secondTimestamp)
|
||||||
|
}
|
||||||
|
// Keep the nondeterministic ordering in storage
|
||||||
|
a.logger.Error("unable to parse activity log timestamps", "timestamp",
|
||||||
|
months[i].Timestamp, "error", errOne, "timestamp", months[j].Timestamp, "error", errTwo)
|
||||||
|
return i < j
|
||||||
})
|
})
|
||||||
|
|
||||||
// Within each month sort everything by descending order of activity
|
// Within each month sort everything by descending order of activity
|
||||||
@ -2476,9 +2484,17 @@ func (a *ActivityLog) partialMonthClientCount(ctx context.Context) (map[string]i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the months in the descending order of activity
|
// Sort the months in ascending order of timestamps
|
||||||
sort.Slice(months, func(i, j int) bool {
|
sort.Slice(months, func(i, j int) bool {
|
||||||
return months[i].Counts.Clients > months[j].Counts.Clients
|
firstTimestamp, errOne := time.Parse(time.RFC3339, months[i].Timestamp)
|
||||||
|
secondTimestamp, errTwo := time.Parse(time.RFC3339, months[j].Timestamp)
|
||||||
|
if errOne == nil && errTwo == nil {
|
||||||
|
return firstTimestamp.Before(secondTimestamp)
|
||||||
|
}
|
||||||
|
// Keep the nondeterministic ordering in storage
|
||||||
|
a.logger.Error("unable to parse activity log timestamps for partial client count",
|
||||||
|
"timestamp", months[i].Timestamp, "error", errOne, "timestamp", months[j].Timestamp, "error", errTwo)
|
||||||
|
return i < j
|
||||||
})
|
})
|
||||||
|
|
||||||
// Within each month sort everything by descending order of activity
|
// Within each month sort everything by descending order of activity
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user