fix: 补齐渠道全量合计筛选导出及有效端目标遗漏
This commit is contained in:
@@ -30,6 +30,7 @@ type AnalyticsFilter struct {
|
||||
Sources, GameNames []string
|
||||
PromoteName string
|
||||
PromoteType *int
|
||||
HasRegister, HasPay *bool
|
||||
StartDate, EndDate *time.Time
|
||||
Begin, End, SortField string
|
||||
Ascending bool
|
||||
@@ -113,6 +114,12 @@ func analyticsValues(row *AnalyticsRow) error {
|
||||
return nil
|
||||
}
|
||||
func (uc *AnalyticsUsecase) List(ctx context.Context, kind AnalyticsKind, filter AnalyticsFilter, page, size int) (*AnalyticsPage, error) {
|
||||
return uc.list(ctx, kind, filter, page, size, false)
|
||||
}
|
||||
func (uc *AnalyticsUsecase) ListAll(ctx context.Context, kind AnalyticsKind, filter AnalyticsFilter) (*AnalyticsPage, error) {
|
||||
return uc.list(ctx, kind, filter, 1, 0, true)
|
||||
}
|
||||
func (uc *AnalyticsUsecase) list(ctx context.Context, kind AnalyticsKind, filter AnalyticsFilter, page, size int, all bool) (*AnalyticsPage, error) {
|
||||
actor, account, err := uc.accounts.actor(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -130,16 +137,23 @@ func (uc *AnalyticsUsecase) List(ctx context.Context, kind AnalyticsKind, filter
|
||||
filter.PromoteName = ""
|
||||
filter.PromoteType = nil
|
||||
}
|
||||
if filter.StartDate == nil || filter.EndDate == nil {
|
||||
if filter.EndDate == nil || kind == GameAnalytics && filter.StartDate == nil {
|
||||
now := uc.now().In(portraitLocation)
|
||||
day := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, portraitLocation)
|
||||
filter.StartDate = &day
|
||||
filter.EndDate = &day
|
||||
if kind == GameAnalytics && filter.StartDate == nil {
|
||||
filter.StartDate = &day
|
||||
}
|
||||
if filter.EndDate == nil {
|
||||
filter.EndDate = &day
|
||||
}
|
||||
}
|
||||
if filter.EndDate.Before(*filter.StartDate) {
|
||||
if filter.StartDate != nil && filter.EndDate.Before(*filter.StartDate) {
|
||||
return nil, ErrAnalyticsDateOrder
|
||||
}
|
||||
filter.Begin = filter.StartDate.Format("2006-01-02")
|
||||
filter.Begin = ""
|
||||
if filter.StartDate != nil {
|
||||
filter.Begin = filter.StartDate.Format("2006-01-02")
|
||||
}
|
||||
filter.End = filter.EndDate.Format("2006-01-02")
|
||||
out := &AnalyticsPage{Rows: []*AnalyticsRow{}, Begin: filter.Begin, End: filter.End, Available: true}
|
||||
scope := AnalyticsScope{Viewer: viewer, IncludeSub: pref.IncludeSubPromote, IDCardDedup: pref.IDCardDedup}
|
||||
@@ -221,6 +235,18 @@ func (uc *AnalyticsUsecase) List(ctx context.Context, kind AnalyticsKind, filter
|
||||
return nil, err
|
||||
}
|
||||
out.Total = int64(len(data.Rows))
|
||||
if all {
|
||||
if out.Total > 10000 {
|
||||
return nil, ErrLedgerExportLimit
|
||||
}
|
||||
out.Rows = data.Rows
|
||||
if !namesBeforeSort {
|
||||
if err := fillNames(out.Rows); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
@@ -243,7 +269,7 @@ func (uc *AnalyticsUsecase) List(ctx context.Context, kind AnalyticsKind, filter
|
||||
return out, nil
|
||||
}
|
||||
func sortAnalytics(rows []*AnalyticsRow, kind AnalyticsKind, field string, ascending bool) error {
|
||||
if kind == GameAnalytics && field == "" {
|
||||
if field == "" {
|
||||
sort.SliceStable(rows, func(i, j int) bool {
|
||||
if rows[i].SourceDB != rows[j].SourceDB {
|
||||
return rows[i].SourceDB < rows[j].SourceDB
|
||||
|
||||
Reference in New Issue
Block a user