mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Don't return a 204 if there's no historical data (#17935)
* don't return a 204 if there's no historical data * add changelog
This commit is contained in:
3
changelog/17935.txt
Normal file
3
changelog/17935.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:bug
|
||||||
|
core/activity: return partial month counts when querying a historical date range and no historical data exists.
|
||||||
|
```
|
||||||
@@ -1546,10 +1546,19 @@ func (a *ActivityLog) handleQuery(ctx context.Context, startTime, endTime time.T
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if storedQuery == nil {
|
if storedQuery == nil {
|
||||||
return nil, nil
|
// If the storedQuery is nil, that means there's no historical data to process. But, it's possible there's
|
||||||
|
// still current month data to process, so rather than returning a 204, let's proceed along like we're
|
||||||
|
// just querying the current month.
|
||||||
|
storedQuery = &activity.PrecomputedQuery{
|
||||||
|
StartTime: startTime,
|
||||||
|
EndTime: endTime,
|
||||||
|
Namespaces: make([]*activity.NamespaceRecord, 0),
|
||||||
|
Months: make([]*activity.MonthRecord, 0),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pq = storedQuery
|
pq = storedQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the namespace response breakdowns and totals for entities and tokens from the initial
|
// Calculate the namespace response breakdowns and totals for entities and tokens from the initial
|
||||||
// namespace data.
|
// namespace data.
|
||||||
totalEntities, totalTokens, byNamespaceResponse, err := a.calculateByNamespaceResponseForQuery(ctx, pq.Namespaces)
|
totalEntities, totalTokens, byNamespaceResponse, err := a.calculateByNamespaceResponseForQuery(ctx, pq.Namespaces)
|
||||||
@@ -1584,6 +1593,7 @@ func (a *ActivityLog) handleQuery(ctx context.Context, startTime, endTime time.T
|
|||||||
// Add the current month's namespace data the precomputed query namespaces
|
// Add the current month's namespace data the precomputed query namespaces
|
||||||
byNamespaceResponse = append(byNamespaceResponse, byNamespaceResponseCurrent...)
|
byNamespaceResponse = append(byNamespaceResponse, byNamespaceResponseCurrent...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort clients within each namespace
|
// Sort clients within each namespace
|
||||||
a.sortALResponseNamespaces(byNamespaceResponse)
|
a.sortALResponseNamespaces(byNamespaceResponse)
|
||||||
|
|
||||||
@@ -1597,11 +1607,13 @@ func (a *ActivityLog) handleQuery(ctx context.Context, startTime, endTime time.T
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the namespace attribution for the current month to the newly computed current month value. Note
|
// 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
|
// 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
|
// primary use-case being for precomputedQueryWorker, but we will reuse this code for brevity and extract
|
||||||
// the namespaces from it.
|
// the namespaces from it.
|
||||||
currentMonthNamespaceAttribution := a.transformMonthBreakdowns(partialByMonth)
|
currentMonthNamespaceAttribution := a.transformMonthBreakdowns(partialByMonth)
|
||||||
|
|
||||||
// Ensure that there is only one element in this list -- if not, warn.
|
// Ensure that there is only one element in this list -- if not, warn.
|
||||||
if len(currentMonthNamespaceAttribution) > 1 {
|
if len(currentMonthNamespaceAttribution) > 1 {
|
||||||
a.logger.Warn("more than one month worth of namespace and mount attribution calculated for "+
|
a.logger.Warn("more than one month worth of namespace and mount attribution calculated for "+
|
||||||
|
|||||||
Reference in New Issue
Block a user