Browse Source

解决用户分析统计未激活用户问题。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.5.1^2
zouap 3 years ago
parent
commit
17bb072640
2 changed files with 12 additions and 12 deletions
  1. +10
    -10
      models/user_business_analysis.go
  2. +2
    -2
      routers/repo/user_data_analysis.go

+ 10
- 10
models/user_business_analysis.go View File

@@ -279,11 +279,11 @@ func postDeal(userMetricsList []*UserMetrics) []*UserMetrics {
return duplicateRemovalUserMetricsList
}

func QueryMetricsForAll() []*UserMetrics {
func QueryMetricsForAll(start int64, end int64) []*UserMetrics {
statictisSess := xStatistic.NewSession()
defer statictisSess.Close()
userMetricsList := make([]*UserMetrics, 0)
if err := statictisSess.Table(new(UserMetrics)).OrderBy("count_date desc").
if err := statictisSess.Table(new(UserMetrics)).Where("count_date >" + fmt.Sprint(start) + " and count_date<" + fmt.Sprint(end)).OrderBy("count_date desc").
Find(&userMetricsList); err != nil {
return nil
}
@@ -291,11 +291,9 @@ func QueryMetricsForAll() []*UserMetrics {
return makeResultForMonth(duplicateRemovalUserMetricsList, len(duplicateRemovalUserMetricsList))
}

func QueryMetricsForYear() []*UserMetrics {
currentTimeNow := time.Now()
currentYearEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location())
currentYearStartTime := time.Date(currentTimeNow.Year(), 1, 1, 0, 0, 0, 0, currentTimeNow.Location())
allUserInfo, count := QueryMetrics(currentYearStartTime.Unix(), currentYearEndTime.Unix())
func QueryMetricsForYear(start int64, end int64) []*UserMetrics {

allUserInfo, count := QueryMetrics(start, end)

return makeResultForMonth(allUserInfo, count)
}
@@ -792,7 +790,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time,
statictisSess := xStatistic.NewSession()
defer statictisSess.Close()

cond := "type != 1 and is_active=true"
cond := "type != 1"
count, err := sess.Where(cond).Count(new(User))
if err != nil {
log.Info("query user error. return.")
@@ -814,8 +812,6 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time,
log.Info("i=" + fmt.Sprint(i) + " userName=" + userRecord.Name)
dateRecord.CountDate = CountDate.Unix()

statictisSess.Delete(&dateRecord)

dateRecord.Email = userRecord.Email
dateRecord.RegistDate = userRecord.CreatedUnix
dateRecord.Name = userRecord.Name
@@ -873,6 +869,10 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time,
if getUserActivate(dateRecord) > 0 {
addUserToMap(userNewAddActivity, userRecord.CreatedUnix, dateRecord.ID)
}
if userRecord.IsActive {
continue
}
statictisSess.Delete(&dateRecord)
_, err = statictisSess.Insert(&dateRecord)
if err != nil {
log.Info("insert daterecord failed." + err.Error())


+ 2
- 2
routers/repo/user_data_analysis.go View File

@@ -265,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)


Loading…
Cancel
Save