|
|
@@ -47,9 +47,7 @@ func writeUserMetricsExcel(row int, xlsx *excelize.File, sheetName string, userM |
|
|
|
rows := fmt.Sprint(row) |
|
|
|
var tmp byte |
|
|
|
tmp = 0 |
|
|
|
dateTime := time.Unix(userMetrics.CountDate, 0) |
|
|
|
//dateTime.Format("2006-01-02 15:04:05") |
|
|
|
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, dateTime.Format("2006-01-02 15:04:05")) |
|
|
|
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userMetrics.DisplayDate) |
|
|
|
tmp = tmp + 1 |
|
|
|
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userMetrics.ActivateRegistUser+userMetrics.NotActivateRegistUser) |
|
|
|
tmp = tmp + 1 |
|
|
@@ -267,10 +265,10 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e |
|
|
|
var count int64 |
|
|
|
result := make([]*models.UserMetrics, 0) |
|
|
|
if tableName == "public.user_business_analysis_current_year" { |
|
|
|
result = models.QueryMetricsForYear() |
|
|
|
result = models.QueryMetricsForYear(startTime.Unix(), endTime.Unix()) |
|
|
|
count = int64(len(result)) |
|
|
|
} else if tableName == "public.user_business_analysis_all" { |
|
|
|
result = models.QueryMetricsForAll() |
|
|
|
result = models.QueryMetricsForAll(startTime.Unix(), endTime.Unix()) |
|
|
|
count = int64(len(result)) |
|
|
|
} else { |
|
|
|
result, count = models.QueryMetricsPage(startTime.Unix(), endTime.Unix(), page, pageSize) |
|
|
@@ -331,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()) |
|
|
@@ -346,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) |
|
|
|
} |
|
|
@@ -355,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) |
|
|
|
} |
|
|
@@ -364,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) |
|
|
|
} |
|
|
@@ -374,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) |
|
|
|
} |
|
|
@@ -383,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) |
|
|
|
} |
|
|
@@ -392,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) |
|
|
|
} |
|
|
|