Account for mount counts when de-duplicating current and historical month data (#18598)
* Account for mount counts when de-duplicating current and historical month data * add changelog
This commit is contained in:
parent
e7787a94e0
commit
c8a8c21cee
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:bug
|
||||||
|
core/activity: include mount counts when de-duplicating current and historical month data
|
||||||
|
```
|
|
@ -1598,15 +1598,37 @@ func (a *ActivityLog) handleQuery(ctx context.Context, startTime, endTime time.T
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rather than blindly appending, which will create duplicates, check our existing counts against the current
|
// Rather than blindly appending, which will create duplicates, check our existing counts against the current
|
||||||
// month counts, and append or update as necessary.
|
// month counts, and append or update as necessary. We also want to account for mounts and their counts.
|
||||||
for _, nrc := range byNamespaceResponseCurrent {
|
for _, nrc := range byNamespaceResponseCurrent {
|
||||||
if ndx, ok := nsrMap[nrc.NamespaceID]; ok {
|
if ndx, ok := nsrMap[nrc.NamespaceID]; ok {
|
||||||
existingRecord := byNamespaceResponse[ndx]
|
existingRecord := byNamespaceResponse[ndx]
|
||||||
|
|
||||||
|
// Create a map of the existing mounts, so we don't duplicate them
|
||||||
|
mountMap := make(map[string]*ResponseCounts)
|
||||||
|
for _, erm := range existingRecord.Mounts {
|
||||||
|
mountMap[erm.MountPath] = erm.Counts
|
||||||
|
}
|
||||||
|
|
||||||
existingRecord.Counts.EntityClients += nrc.Counts.EntityClients
|
existingRecord.Counts.EntityClients += nrc.Counts.EntityClients
|
||||||
existingRecord.Counts.Clients += nrc.Counts.Clients
|
existingRecord.Counts.Clients += nrc.Counts.Clients
|
||||||
existingRecord.Counts.DistinctEntities += nrc.Counts.DistinctEntities
|
existingRecord.Counts.DistinctEntities += nrc.Counts.DistinctEntities
|
||||||
existingRecord.Counts.NonEntityClients += nrc.Counts.NonEntityClients
|
existingRecord.Counts.NonEntityClients += nrc.Counts.NonEntityClients
|
||||||
existingRecord.Counts.NonEntityTokens += nrc.Counts.NonEntityTokens
|
existingRecord.Counts.NonEntityTokens += nrc.Counts.NonEntityTokens
|
||||||
|
|
||||||
|
// Check the current month mounts against the existing mounts and if there are matches, update counts
|
||||||
|
// accordingly. If there is no match, append the new mount to the existing mounts, so it will be counted
|
||||||
|
// later.
|
||||||
|
for _, nrcMount := range nrc.Mounts {
|
||||||
|
if existingRecordMountCounts, ook := mountMap[nrcMount.MountPath]; ook {
|
||||||
|
existingRecordMountCounts.EntityClients += nrcMount.Counts.EntityClients
|
||||||
|
existingRecordMountCounts.Clients += nrcMount.Counts.Clients
|
||||||
|
existingRecordMountCounts.DistinctEntities += nrcMount.Counts.DistinctEntities
|
||||||
|
existingRecordMountCounts.NonEntityClients += nrcMount.Counts.NonEntityClients
|
||||||
|
existingRecordMountCounts.NonEntityTokens += nrcMount.Counts.NonEntityTokens
|
||||||
|
} else {
|
||||||
|
existingRecord.Mounts = append(existingRecord.Mounts, nrcMount)
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
byNamespaceResponse = append(byNamespaceResponse, nrc)
|
byNamespaceResponse = append(byNamespaceResponse, nrc)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue