Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/2098 Reviewed-by: lewis <747342561@qq.com>pull/2112/head
@@ -233,19 +233,15 @@ func QueryMetricsPage(start int64, end int64, page int, pageSize int) ([]*UserMe | |||
statictisSess := xStatistic.NewSession() | |||
defer statictisSess.Close() | |||
cond := "count_date >" + fmt.Sprint(start) + " and count_date<" + fmt.Sprint(end) | |||
allCount, err := statictisSess.Where(cond).Count(new(UserMetrics)) | |||
if err != nil { | |||
log.Info("query error." + err.Error()) | |||
return nil, 0 | |||
} | |||
userMetricsList := make([]*UserMetrics, 0) | |||
//.Limit(pageSize, page*pageSize) | |||
if err := statictisSess.Table(new(UserMetrics)).Where(cond).OrderBy("count_date desc"). | |||
Find(&userMetricsList); err != nil { | |||
return nil, 0 | |||
} | |||
postDeal(userMetricsList) | |||
return userMetricsList, allCount | |||
postUserMetricsList := postDeal(userMetricsList) | |||
return postUserMetricsList, int64(len(postUserMetricsList)) | |||
} | |||
func QueryMetrics(start int64, end int64) ([]*UserMetrics, int) { | |||
@@ -256,16 +252,31 @@ func QueryMetrics(start int64, end int64) ([]*UserMetrics, int) { | |||
Find(&userMetricsList); err != nil { | |||
return nil, 0 | |||
} | |||
postDeal(userMetricsList) | |||
return userMetricsList, len(userMetricsList) | |||
postUserMetricsList := postDeal(userMetricsList) | |||
return postUserMetricsList, int(len(postUserMetricsList)) | |||
} | |||
func duplicateRemoval(userMetricsList []*UserMetrics) []*UserMetrics { | |||
userMetricsResult := make([]*UserMetrics, 0) | |||
for i := 0; i < len(userMetricsList); i++ { | |||
if i > 0 { | |||
if userMetricsList[i].DataDate == userMetricsList[i-1].DataDate { | |||
continue | |||
} | |||
} | |||
userMetricsResult = append(userMetricsResult, userMetricsList[i]) | |||
} | |||
return userMetricsResult | |||
} | |||
func postDeal(userMetricsList []*UserMetrics) { | |||
for _, userMetrics := range userMetricsList { | |||
func postDeal(userMetricsList []*UserMetrics) []*UserMetrics { | |||
duplicateRemovalUserMetricsList := duplicateRemoval(userMetricsList) | |||
for _, userMetrics := range duplicateRemovalUserMetricsList { | |||
userMetrics.DisplayDate = userMetrics.DataDate | |||
userMetrics.TotalRegistUser = userMetrics.ActivateRegistUser + userMetrics.NotActivateRegistUser | |||
userMetrics.TotalNotActivateRegistUser = userMetrics.TotalUser - userMetrics.TotalActivateRegistUser | |||
} | |||
return duplicateRemovalUserMetricsList | |||
} | |||
func QueryMetricsForAll() []*UserMetrics { | |||
@@ -276,7 +287,8 @@ func QueryMetricsForAll() []*UserMetrics { | |||
Find(&userMetricsList); err != nil { | |||
return nil | |||
} | |||
return makeResultForMonth(userMetricsList, len(userMetricsList)) | |||
duplicateRemovalUserMetricsList := duplicateRemoval(userMetricsList) | |||
return makeResultForMonth(duplicateRemovalUserMetricsList, len(duplicateRemovalUserMetricsList)) | |||
} | |||
func QueryMetricsForYear() []*UserMetrics { | |||
@@ -879,9 +891,9 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, | |||
//insert userMetrics table | |||
var useMetrics UserMetrics | |||
useMetrics.CountDate = CountDate.Unix() | |||
useMetrics.DataDate = DataDate | |||
statictisSess.Delete(&useMetrics) | |||
useMetrics.DataDate = DataDate | |||
useMetrics.ActivateRegistUser = getMapKeyStringValue("ActivateRegistUser", userMetrics) | |||
useMetrics.HasActivityUser = getMapKeyStringValue("HasActivityUser", userMetrics) | |||
useMetrics.RegistActivityUser = 0 | |||
@@ -1,11 +1,12 @@ | |||
package cloudbrain | |||
import ( | |||
"code.gitea.io/gitea/modules/timeutil" | |||
"encoding/json" | |||
"errors" | |||
"strconv" | |||
"code.gitea.io/gitea/modules/timeutil" | |||
"code.gitea.io/gitea/modules/storage" | |||
"code.gitea.io/gitea/models" | |||
@@ -186,7 +187,6 @@ func AdminOrImageCreaterRight(ctx *context.Context) { | |||
} | |||
func GenerateTask(ctx *context.Context, displayJobName, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, brainScorePath, jobType, gpuQueue, description, branchName, bootFile, params string, benchmarkTypeID, benchmarkChildTypeID, resourceSpecId int) error { | |||
dataActualPath := setting.Attachment.Minio.RealPath + | |||
@@ -6,9 +6,10 @@ | |||
package private | |||
import ( | |||
"code.gitea.io/gitea/routers/repo" | |||
"strings" | |||
"code.gitea.io/gitea/routers/repo" | |||
"code.gitea.io/gitea/modules/log" | |||
"code.gitea.io/gitea/modules/private" | |||
"code.gitea.io/gitea/modules/setting" | |||
@@ -46,7 +47,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
m.Post("/manager/flush-queues", bind(private.FlushOptions{}), FlushQueues) | |||
m.Post("/tool/update_all_repo_commit_cnt", UpdateAllRepoCommitCnt) | |||
m.Post("/tool/repo_stat/:date", RepoStatisticManually) | |||
m.Post("/tool/user_stat/:date", UserStatisticManually) | |||
m.Get("/tool/org_stat", OrgStatisticManually) | |||
m.Post("/tool/update_repo_visit/:date", UpdateRepoVisit) | |||
m.Post("/task/history_handle/duration", repo.HandleTaskWithNoDuration) | |||
@@ -45,6 +45,11 @@ func RepoStatisticManually(ctx *macaron.Context) { | |||
repo.TimingCountDataByDate(date) | |||
} | |||
func UserStatisticManually(ctx *macaron.Context) { | |||
date := ctx.Params("date") | |||
repo.TimingCountDataByDate(date) | |||
} | |||
func OrgStatisticManually() { | |||
models.UpdateOrgStatistics() | |||
} | |||
@@ -247,6 +247,7 @@ func queryUserDataPage(ctx *context.Context, tableName string, queryObj interfac | |||
mapInterface := make(map[string]interface{}) | |||
mapInterface["data"] = re | |||
mapInterface["count"] = count | |||
ctx.JSON(http.StatusOK, mapInterface) | |||
} | |||
} | |||
@@ -303,6 +304,15 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e | |||
mapInterface := make(map[string]interface{}) | |||
mapInterface["data"] = result | |||
mapInterface["count"] = count | |||
if tableName == "public.user_business_analysis_yesterday" { | |||
mapInterface["datarecordbegintime"] = setting.RadarMap.GrowthBeginTime | |||
if len(result) > 0 { | |||
dateTime := time.Unix(result[0].CountDate, 0) | |||
mapInterface["lastUpdatedTime"] = dateTime.Format("2006-01-02 15:04:05") | |||
} else { | |||
mapInterface["lastUpdatedTime"] = "" | |||
} | |||
} | |||
ctx.JSON(http.StatusOK, mapInterface) | |||
} | |||
@@ -257,10 +257,10 @@ | |||
return days; | |||
}, | |||
getUpdateTime(){ | |||
this.$axios.get('../../api/v1/projectboard/project',{ | |||
this.$axios.get('../../api/v1/query_metrics_yesterday',{ | |||
params:this.params_pro | |||
}).then((res)=>{ | |||
this.recordBeginTime=res.data.recordBeginTime | |||
this.recordBeginTime=res.data.datarecordbegintime | |||
this.lastUpdatedTime=res.data.lastUpdatedTime | |||
}) | |||
}, | |||