|
@@ -251,9 +251,7 @@ func queryUserDataPage(ctx *context.Context, tableName string, queryObj interfac |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func queryMetrics(ctx *context.Context, tableName string) { |
|
|
|
|
|
startDate := ctx.Query("startDate") |
|
|
|
|
|
endDate := ctx.Query("endDate") |
|
|
|
|
|
|
|
|
func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, endTime time.Time) { |
|
|
|
|
|
|
|
|
page := ctx.QueryInt("page") |
|
|
page := ctx.QueryInt("page") |
|
|
if page <= 0 { |
|
|
if page <= 0 { |
|
@@ -274,8 +272,6 @@ func queryMetrics(ctx *context.Context, tableName string) { |
|
|
result = models.QueryMetricsForAll() |
|
|
result = models.QueryMetricsForAll() |
|
|
count = int64(len(result)) |
|
|
count = int64(len(result)) |
|
|
} else { |
|
|
} else { |
|
|
startTime, _ := time.ParseInLocation("2006-01-02", startDate, time.Local) |
|
|
|
|
|
endTime, _ := time.ParseInLocation("2006-01-02", endDate, time.Local) |
|
|
|
|
|
result, count = models.QueryMetricsPage(startTime.Unix(), endTime.Unix(), page, pageSize) |
|
|
result, count = models.QueryMetricsPage(startTime.Unix(), endTime.Unix(), page, pageSize) |
|
|
} |
|
|
} |
|
|
if IsReturnFile { |
|
|
if IsReturnFile { |
|
@@ -325,43 +321,69 @@ func QueryRankingList(ctx *context.Context) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func QueryUserMetricsCurrentMonth(ctx *context.Context) { |
|
|
func QueryUserMetricsCurrentMonth(ctx *context.Context) { |
|
|
queryMetrics(ctx, "public.user_business_analysis_current_month") |
|
|
|
|
|
|
|
|
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()) |
|
|
|
|
|
queryMetrics(ctx, "public.user_business_analysis_current_month", pageStartTime, pageEndTime) |
|
|
} |
|
|
} |
|
|
func QueryUserStaticCurrentMonth(ctx *context.Context) { |
|
|
func QueryUserStaticCurrentMonth(ctx *context.Context) { |
|
|
queryUserDataPage(ctx, "public.user_business_analysis_current_month", new(models.UserBusinessAnalysisCurrentMonth)) |
|
|
queryUserDataPage(ctx, "public.user_business_analysis_current_month", new(models.UserBusinessAnalysisCurrentMonth)) |
|
|
} |
|
|
} |
|
|
func QueryUserMetricsCurrentWeek(ctx *context.Context) { |
|
|
func QueryUserMetricsCurrentWeek(ctx *context.Context) { |
|
|
queryMetrics(ctx, "public.user_business_analysis_current_week") |
|
|
|
|
|
|
|
|
currentTimeNow := time.Now() |
|
|
|
|
|
offset := int(time.Monday - currentTimeNow.Weekday()) |
|
|
|
|
|
if offset > 0 { |
|
|
|
|
|
offset = -6 |
|
|
|
|
|
} |
|
|
|
|
|
pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset) |
|
|
|
|
|
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) |
|
|
} |
|
|
} |
|
|
func QueryUserStaticCurrentWeek(ctx *context.Context) { |
|
|
func QueryUserStaticCurrentWeek(ctx *context.Context) { |
|
|
queryUserDataPage(ctx, "public.user_business_analysis_current_week", new(models.UserBusinessAnalysisCurrentWeek)) |
|
|
queryUserDataPage(ctx, "public.user_business_analysis_current_week", new(models.UserBusinessAnalysisCurrentWeek)) |
|
|
} |
|
|
} |
|
|
func QueryUserMetricsCurrentYear(ctx *context.Context) { |
|
|
func QueryUserMetricsCurrentYear(ctx *context.Context) { |
|
|
queryMetrics(ctx, "public.user_business_analysis_current_year") |
|
|
|
|
|
|
|
|
currentTimeNow := time.Now() |
|
|
|
|
|
pageStartTime := time.Date(currentTimeNow.Year(), 1, 1, 0, 0, 0, 0, currentTimeNow.Location()) |
|
|
|
|
|
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) |
|
|
} |
|
|
} |
|
|
func QueryUserStaticCurrentYear(ctx *context.Context) { |
|
|
func QueryUserStaticCurrentYear(ctx *context.Context) { |
|
|
queryUserDataPage(ctx, "public.user_business_analysis_current_year", new(models.UserBusinessAnalysisCurrentYear)) |
|
|
queryUserDataPage(ctx, "public.user_business_analysis_current_year", new(models.UserBusinessAnalysisCurrentYear)) |
|
|
} |
|
|
} |
|
|
func QueryUserMetricsLast30Day(ctx *context.Context) { |
|
|
func QueryUserMetricsLast30Day(ctx *context.Context) { |
|
|
queryMetrics(ctx, "public.user_business_analysis_last30_day") |
|
|
|
|
|
|
|
|
currentTimeNow := time.Now() |
|
|
|
|
|
pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, -30) |
|
|
|
|
|
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) |
|
|
} |
|
|
} |
|
|
func QueryUserStaticLast30Day(ctx *context.Context) { |
|
|
func QueryUserStaticLast30Day(ctx *context.Context) { |
|
|
queryUserDataPage(ctx, "public.user_business_analysis_last30_day", new(models.UserBusinessAnalysisLast30Day)) |
|
|
queryUserDataPage(ctx, "public.user_business_analysis_last30_day", new(models.UserBusinessAnalysisLast30Day)) |
|
|
} |
|
|
} |
|
|
func QueryUserMetricsLastMonth(ctx *context.Context) { |
|
|
func QueryUserMetricsLastMonth(ctx *context.Context) { |
|
|
queryMetrics(ctx, "public.user_business_analysis_last_month") |
|
|
|
|
|
|
|
|
currentTimeNow := time.Now() |
|
|
|
|
|
thisMonth := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), 1, 0, 0, 0, 0, currentTimeNow.Location()) |
|
|
|
|
|
pageStartTime := thisMonth.AddDate(0, -1, 0) |
|
|
|
|
|
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) |
|
|
} |
|
|
} |
|
|
func QueryUserStaticLastMonth(ctx *context.Context) { |
|
|
func QueryUserStaticLastMonth(ctx *context.Context) { |
|
|
queryUserDataPage(ctx, "public.user_business_analysis_last_month", new(models.UserBusinessAnalysisLastMonth)) |
|
|
queryUserDataPage(ctx, "public.user_business_analysis_last_month", new(models.UserBusinessAnalysisLastMonth)) |
|
|
} |
|
|
} |
|
|
func QueryUserMetricsYesterday(ctx *context.Context) { |
|
|
func QueryUserMetricsYesterday(ctx *context.Context) { |
|
|
queryMetrics(ctx, "public.user_business_analysis_yesterday") |
|
|
|
|
|
|
|
|
currentTimeNow := time.Now() |
|
|
|
|
|
pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, -1) |
|
|
|
|
|
pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()).AddDate(0, 0, -1) |
|
|
|
|
|
queryMetrics(ctx, "public.user_business_analysis_yesterday", pageStartTime, pageEndTime) |
|
|
} |
|
|
} |
|
|
func QueryUserStaticYesterday(ctx *context.Context) { |
|
|
func QueryUserStaticYesterday(ctx *context.Context) { |
|
|
queryUserDataPage(ctx, "public.user_business_analysis_yesterday", new(models.UserBusinessAnalysisYesterday)) |
|
|
queryUserDataPage(ctx, "public.user_business_analysis_yesterday", new(models.UserBusinessAnalysisYesterday)) |
|
|
} |
|
|
} |
|
|
func QueryUserMetricsAll(ctx *context.Context) { |
|
|
func QueryUserMetricsAll(ctx *context.Context) { |
|
|
queryMetrics(ctx, "public.user_business_analysis_all") |
|
|
|
|
|
|
|
|
currentTimeNow := time.Now() |
|
|
|
|
|
pageStartTime := time.Date(2022, 4, 5, 0, 0, 0, 0, currentTimeNow.Location()) |
|
|
|
|
|
pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) |
|
|
|
|
|
queryMetrics(ctx, "public.user_business_analysis_all", pageStartTime, pageEndTime) |
|
|
} |
|
|
} |
|
|
func QueryUserStaticAll(ctx *context.Context) { |
|
|
func QueryUserStaticAll(ctx *context.Context) { |
|
|
queryUserDataPage(ctx, "public.user_business_analysis_all", new(models.UserBusinessAnalysisAll)) |
|
|
queryUserDataPage(ctx, "public.user_business_analysis_all", new(models.UserBusinessAnalysisAll)) |
|
|