|
|
@@ -110,9 +110,9 @@ type UserBusinessAnalysisAll struct { |
|
|
|
} |
|
|
|
|
|
|
|
type UserBusinessAnalysis struct { |
|
|
|
ID int64 `xorm:"pk"` |
|
|
|
|
|
|
|
CountDate int64 `xorm:"pk"` |
|
|
|
ID int64 `xorm:"pk"` |
|
|
|
DataDate string `xorm:"pk"` |
|
|
|
CountDate int64 `xorm:"NULL"` |
|
|
|
|
|
|
|
//action :ActionMergePullRequest // 11 |
|
|
|
CodeMergeCount int `xorm:"NOT NULL DEFAULT 0"` |
|
|
@@ -171,8 +171,6 @@ type UserBusinessAnalysis struct { |
|
|
|
//user |
|
|
|
Name string `xorm:"NOT NULL"` |
|
|
|
|
|
|
|
DataDate string `xorm:"NULL"` |
|
|
|
|
|
|
|
CloudBrainTaskNum int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
GpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
NpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
@@ -411,6 +409,42 @@ func QueryUserStaticDataAll(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusi |
|
|
|
return userBusinessAnalysisReturnList, allCount |
|
|
|
} |
|
|
|
|
|
|
|
func QueryDataForUserDefineFromDb(opts *UserBusinessAnalysisQueryOptions, key string) ([]*UserBusinessAnalysis, int64) { |
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
|
defer statictisSess.Close() |
|
|
|
|
|
|
|
allCount, err := statictisSess.Where("data_date=" + key).Count(new(UserBusinessAnalysis)) |
|
|
|
if err == nil { |
|
|
|
if allCount > 0 { |
|
|
|
userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) |
|
|
|
if err := statictisSess.Table("user_business_analysis").Where("data_date="+key).OrderBy("id desc").Limit(opts.PageSize, (opts.Page-1)*opts.PageSize). |
|
|
|
Find(&userBusinessAnalysisList); err != nil { |
|
|
|
return nil, 0 |
|
|
|
} |
|
|
|
return userBusinessAnalysisList, allCount |
|
|
|
} |
|
|
|
} |
|
|
|
return nil, 0 |
|
|
|
} |
|
|
|
|
|
|
|
func WriteDataToDb(dataList []*UserBusinessAnalysis, key string) { |
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
|
defer statictisSess.Close() |
|
|
|
log.Info("write to db, size=" + fmt.Sprint(len(dataList))) |
|
|
|
userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) |
|
|
|
for _, data := range dataList { |
|
|
|
data.DataDate = key |
|
|
|
userBusinessAnalysisList = append(userBusinessAnalysisList, data) |
|
|
|
if len(userBusinessAnalysisList) > BATCH_INSERT_SIZE { |
|
|
|
statictisSess.Insert(userBusinessAnalysisList) |
|
|
|
userBusinessAnalysisList = make([]*UserBusinessAnalysis, 0) |
|
|
|
} |
|
|
|
} |
|
|
|
if len(userBusinessAnalysisList) > 0 { |
|
|
|
statictisSess.Insert(userBusinessAnalysisList) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wikiCountMap map[string]int) ([]*UserBusinessAnalysis, int64) { |
|
|
|
log.Info("start to count other user info data") |
|
|
|
sess := x.NewSession() |
|
|
@@ -954,6 +988,9 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, |
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
|
defer statictisSess.Close() |
|
|
|
|
|
|
|
log.Info("truncate all data from table:user_business_analysis ") |
|
|
|
statictisSess.Exec("TRUNCATE TABLE user_business_analysis") |
|
|
|
|
|
|
|
cond := "type != 1" |
|
|
|
count, err := sess.Where(cond).Count(new(User)) |
|
|
|
if err != nil { |
|
|
|