mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 02:57:59 +00:00
De-duplicate namespaces when historical and current month data are mixed (#18452)
* De-duplicate namespaces when historical and current month data are mixed * add changelog
This commit is contained in:
3
changelog/18452.txt
Normal file
3
changelog/18452.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:bug
|
||||||
|
core/activity: de-duplicate namespaces when historical and current month data are mixed
|
||||||
|
```
|
||||||
@@ -1590,8 +1590,27 @@ func (a *ActivityLog) handleQuery(ctx context.Context, startTime, endTime time.T
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the current month's namespace data the precomputed query namespaces
|
// Create a mapping of namespace id to slice index, so that we can efficiently update our results without
|
||||||
byNamespaceResponse = append(byNamespaceResponse, byNamespaceResponseCurrent...)
|
// having to traverse the entire namespace response slice every time.
|
||||||
|
nsrMap := make(map[string]int)
|
||||||
|
for i, nr := range byNamespaceResponse {
|
||||||
|
nsrMap[nr.NamespaceID] = i
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rather than blindly appending, which will create duplicates, check our existing counts against the current
|
||||||
|
// month counts, and append or update as necessary.
|
||||||
|
for _, nrc := range byNamespaceResponseCurrent {
|
||||||
|
if ndx, ok := nsrMap[nrc.NamespaceID]; ok {
|
||||||
|
existingRecord := byNamespaceResponse[ndx]
|
||||||
|
existingRecord.Counts.EntityClients += nrc.Counts.EntityClients
|
||||||
|
existingRecord.Counts.Clients += nrc.Counts.Clients
|
||||||
|
existingRecord.Counts.DistinctEntities += nrc.Counts.DistinctEntities
|
||||||
|
existingRecord.Counts.NonEntityClients += nrc.Counts.NonEntityClients
|
||||||
|
existingRecord.Counts.NonEntityTokens += nrc.Counts.NonEntityTokens
|
||||||
|
} else {
|
||||||
|
byNamespaceResponse = append(byNamespaceResponse, nrc)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort clients within each namespace
|
// Sort clients within each namespace
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ func parseStartEndTimes(a *ActivityLog, d *framework.FieldData) (time.Time, time
|
|||||||
return startTime, endTime, nil
|
return startTime, endTime, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This endpoint is not used by the UI. The UI's "export" feature is entirely client-side.
|
||||||
func (b *SystemBackend) handleClientExport(ctx context.Context, req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
|
func (b *SystemBackend) handleClientExport(ctx context.Context, req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
|
||||||
a := b.Core.activityLog
|
a := b.Core.activityLog
|
||||||
if a == nil {
|
if a == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user