Browse Source

用户年度报告数据统计

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.12.1^2
zouap 3 years ago
parent
commit
223f3de996
3 changed files with 17 additions and 7 deletions
  1. +5
    -2
      models/user_analysis_for_activity.go
  2. +12
    -2
      models/user_business_analysis.go
  3. +0
    -3
      routers/home.go

+ 5
- 2
models/user_analysis_for_activity.go View File

@@ -453,8 +453,11 @@ func QueryUserLoginInfo(userIds []int64) []*UserLoginLog {
func QueryUserAnnualReport(userId int64) *UserSummaryCurrentYear {
statictisSess := xStatistic.NewSession()
defer statictisSess.Close()
log.Info("userId=" + fmt.Sprint(userId))
var re *UserSummaryCurrentYear
statictisSess.ID(userId).Get(re)

_, err := statictisSess.Table(new(UserSummaryCurrentYear)).ID(userId).Get(re)
if err != nil {
log.Info("error:=" + err.Error())
}
return re
}

+ 12
- 2
models/user_business_analysis.go View File

@@ -610,7 +610,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS

DataDate := currentTimeNow.Format("2006-01-02") + " 00:01"
bonusMap := make(map[string]map[string]int)
if tableName == "user_business_analysis_current_year" {
if isUserYearData(tableName) {
bonusMap = getBonusMap()
log.Info("truncate all data from table:user_summary_current_year ")
statictisSess.Exec("TRUNCATE TABLE user_summary_current_year")
@@ -712,7 +712,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS
userMetrics["TotalHasActivityUser"] = getMapKeyStringValue("TotalHasActivityUser", userMetrics) + 1
}
}
if tableName == "user_business_analysis_current_year" {
if isUserYearData(tableName) {
//年度数据
subTime := time.Now().UTC().Sub(dateRecordAll.RegistDate.AsTime().UTC())
mostActiveDay := ""
@@ -772,6 +772,16 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS
log.Info("refresh data finished.tableName=" + tableName + " total record:" + fmt.Sprint(insertCount))
}

func isUserYearData(tableName string) bool {
if tableName == "user_business_analysis_current_year" {
currentTimeNow := time.Now()
if currentTimeNow.Year() >= 2023 {
return false
}
}
return true
}

func getBonusMap() map[string]map[string]int {
bonusMap := make(map[string]map[string]int)
url := setting.RecommentRepoAddr + "bonus/record.txt"


+ 0
- 3
routers/home.go View File

@@ -8,7 +8,6 @@ package routers
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"strconv"
"strings"
@@ -755,13 +754,11 @@ func GetRankUser(index string) ([]map[string]interface{}, error) {
}
resultOrg := make([]map[string]interface{}, 0)
for _, userRank := range result {
log.Info("userRank" + userRank)
tmpIndex := strings.Index(userRank, " ")
userName := userRank
score := 0
label := ""
if tmpIndex != -1 {
log.Info("len=" + fmt.Sprint(len(userRank)) + " index=" + fmt.Sprint(tmpIndex))
userName = userRank[0:tmpIndex]
left := userRank[tmpIndex+1:]
tmpIndex1 := strings.Index(left, " ")


Loading…
Cancel
Save