| @@ -329,14 +329,25 @@ func QueryRankingList(ctx *context.Context) { | |||
| } | |||
| func QueryUserMetricsCurrentMonth(ctx *context.Context) { | |||
| currentTimeNow := time.Now() | |||
| pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) | |||
| pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), 1, 0, 0, 0, 0, currentTimeNow.Location()) | |||
| pageStartTime = getStartTime(pageStartTime) | |||
| queryMetrics(ctx, "public.user_business_analysis_current_month", pageStartTime, pageEndTime) | |||
| } | |||
| func QueryUserStaticCurrentMonth(ctx *context.Context) { | |||
| queryUserDataPage(ctx, "public.user_business_analysis_current_month", new(models.UserBusinessAnalysisCurrentMonth)) | |||
| } | |||
| func getStartTime(pageStartTime time.Time) time.Time { | |||
| t, _ := time.Parse("2006-01-02", setting.RadarMap.GrowthBeginTime) | |||
| if pageStartTime.Before(t) { | |||
| pageStartTime = t | |||
| } | |||
| return pageStartTime | |||
| } | |||
| func QueryUserMetricsCurrentWeek(ctx *context.Context) { | |||
| currentTimeNow := time.Now() | |||
| offset := int(time.Monday - currentTimeNow.Weekday()) | |||
| @@ -344,6 +355,7 @@ func QueryUserMetricsCurrentWeek(ctx *context.Context) { | |||
| offset = -6 | |||
| } | |||
| pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset) | |||
| pageStartTime = getStartTime(pageStartTime) | |||
| pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) | |||
| queryMetrics(ctx, "public.user_business_analysis_current_week", pageStartTime, pageEndTime) | |||
| } | |||
| @@ -353,6 +365,7 @@ func QueryUserStaticCurrentWeek(ctx *context.Context) { | |||
| func QueryUserMetricsCurrentYear(ctx *context.Context) { | |||
| currentTimeNow := time.Now() | |||
| pageStartTime := time.Date(currentTimeNow.Year(), 1, 1, 0, 0, 0, 0, currentTimeNow.Location()) | |||
| pageStartTime = getStartTime(pageStartTime) | |||
| pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) | |||
| queryMetrics(ctx, "public.user_business_analysis_current_year", pageStartTime, pageEndTime) | |||
| } | |||
| @@ -362,6 +375,7 @@ func QueryUserStaticCurrentYear(ctx *context.Context) { | |||
| func QueryUserMetricsLast30Day(ctx *context.Context) { | |||
| currentTimeNow := time.Now() | |||
| pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, -30) | |||
| pageStartTime = getStartTime(pageStartTime) | |||
| pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) | |||
| queryMetrics(ctx, "public.user_business_analysis_last30_day", pageStartTime, pageEndTime) | |||
| } | |||
| @@ -372,6 +386,7 @@ func QueryUserMetricsLastMonth(ctx *context.Context) { | |||
| currentTimeNow := time.Now() | |||
| thisMonth := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), 1, 0, 0, 0, 0, currentTimeNow.Location()) | |||
| pageStartTime := thisMonth.AddDate(0, -1, 0) | |||
| pageStartTime = getStartTime(pageStartTime) | |||
| pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), 1, 23, 59, 59, 0, currentTimeNow.Location()).AddDate(0, 0, -1) | |||
| queryMetrics(ctx, "public.user_business_analysis_last_month", pageStartTime, pageEndTime) | |||
| } | |||
| @@ -381,6 +396,7 @@ func QueryUserStaticLastMonth(ctx *context.Context) { | |||
| func QueryUserMetricsYesterday(ctx *context.Context) { | |||
| currentTimeNow := time.Now() | |||
| pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local) | |||
| pageStartTime = getStartTime(pageStartTime) | |||
| pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) | |||
| queryMetrics(ctx, "public.user_business_analysis_yesterday", pageStartTime, pageEndTime) | |||
| } | |||
| @@ -390,6 +406,7 @@ func QueryUserStaticYesterday(ctx *context.Context) { | |||
| func QueryUserMetricsAll(ctx *context.Context) { | |||
| currentTimeNow := time.Now() | |||
| pageStartTime := time.Date(2022, 4, 5, 0, 0, 0, 0, currentTimeNow.Location()) | |||
| pageStartTime = getStartTime(pageStartTime) | |||
| pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) | |||
| queryMetrics(ctx, "public.user_business_analysis_all", pageStartTime, pageEndTime) | |||
| } | |||