fix: limit channel report rows to the selected period
This commit is contained in:
@@ -216,23 +216,8 @@ func (r *analyticsRepo) Aggregate(ctx context.Context, kind business.AnalyticsKi
|
||||
putAnalyticsCount(&rowFor(po).Counts, po.Metric, po.Count)
|
||||
}
|
||||
}
|
||||
// Keep visible channels with no events in the selected period so that
|
||||
// "no registration / no recharge" can find genuinely inactive channels.
|
||||
if kind == business.ChannelAnalytics && len(f.GameNames) == 0 {
|
||||
root := "p.id"
|
||||
if scope.IncludeSub {
|
||||
root = "CASE WHEN p.promote_level=1 THEN p.id WHEN p.top_promote_id>0 THEN p.top_promote_id ELSE p.id END"
|
||||
}
|
||||
var channels []analyticsAggPO
|
||||
if err := analyticsPromotes(db, scope, f, "p").Select("DISTINCT p.source_db," + root + " AS entity_id").Scan(&channels).Error; err != nil {
|
||||
return nil, business.ErrStorage
|
||||
}
|
||||
for _, po := range channels {
|
||||
if po.ID != nil {
|
||||
rowFor(po)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Report rows come from facts in the selected period. Registration/payment
|
||||
// filters narrow that same set; they must not add the entire channel catalog.
|
||||
if kind == business.ChannelAnalytics && !scope.Viewer.All {
|
||||
if err := filterAnalyticsRows(db, scope, f, rowMap); err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user