re-add namespace attribution to current month (#16473)

* re-add namespace attribution to current month

* delete cl

* parity with ent branch
This commit is contained in:
Hridoy Roy 2022-08-16 16:27:20 -07:00 committed by GitHub
parent 2ab297a24f
commit 91ef527a1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -1,3 +0,0 @@
```release-note:bug
activity: Add timestamp to current month calculation and remove deduplication for current month
```

View File

@ -1570,6 +1570,21 @@ func (a *ActivityLog) handleQuery(ctx context.Context, startTime, endTime time.T
if err != nil {
return nil, err
}
// Add the namespace attribution for the current month to the newly computed current month value. Note
// that transformMonthBreakdowns calculates a superstruct of the required namespace struct due to its
// primary use-case being for precomputedQueryWorker, but we will reuse this code for brevity and extract
// the namespaces from it.
currentMonthNamespaceAttribution := a.transformMonthBreakdowns(partialByMonth)
// Ensure that there is only one element in this list -- if not, warn.
if len(currentMonthNamespaceAttribution) > 1 {
a.logger.Warn("more than one month worth of namespace and mount attribution calculated for "+
"current month values", "number of months", len(currentMonthNamespaceAttribution))
}
if len(currentMonthNamespaceAttribution) == 0 {
a.logger.Warn("no month data found, returning query with no namespace attribution for current month")
} else {
currentMonth.Namespaces = currentMonthNamespaceAttribution[0].Namespaces
}
pq.Months = append(pq.Months, currentMonth)
distinctEntitiesResponse += pq.Months[len(pq.Months)-1].NewClients.Counts.EntityClients
}