perf: exclude inactive catalog rows from report summary lookups
This commit is contained in:
@@ -228,6 +228,13 @@ func (r *analyticsRepo) Aggregate(ctx context.Context, kind business.AnalyticsKi
|
||||
}
|
||||
}
|
||||
if metricFilter {
|
||||
// Only channels present in the report can contribute to its summary.
|
||||
// Keep zero-activity catalog rows out of the aggregate IN list; large
|
||||
// catalogs would otherwise exhaust MySQL's prepared-statement parameters.
|
||||
factKeys := make([]business.AnalyticsKey, 0, len(rowMap))
|
||||
for key := range rowMap {
|
||||
factKeys = append(factKeys, key)
|
||||
}
|
||||
if f.IncludesInactiveRows() {
|
||||
if err := includeInactiveAnalyticsRows(db, scope, f, rowMap); err != nil {
|
||||
return nil, err
|
||||
@@ -243,9 +250,11 @@ func (r *analyticsRepo) Aggregate(ctx context.Context, kind business.AnalyticsKi
|
||||
}
|
||||
}
|
||||
if withGlobal {
|
||||
keys := make([]business.AnalyticsKey, 0, len(rowMap))
|
||||
for key := range rowMap {
|
||||
keys = append(keys, key)
|
||||
keys := make([]business.AnalyticsKey, 0, len(factKeys))
|
||||
for _, key := range factKeys {
|
||||
if rowMap[key] != nil {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
}
|
||||
// Deduplicate identities across all matched channels, before pagination.
|
||||
// Summing per-channel counts would double-count shared players.
|
||||
|
||||
Reference in New Issue
Block a user