Browse Source

Merge remote-tracking branch 'origin/V20221228' into gcu

gcu
chenshihai 2 years ago
parent
commit
f149b9a813
9 changed files with 41 additions and 20 deletions
  1. +1
    -0
      models/cloudbrain.go
  2. +8
    -0
      models/user_analysis_for_activity.go
  3. +17
    -7
      models/user_business_analysis.go
  4. +6
    -1
      modules/context/auth.go
  5. +1
    -1
      options/locale/locale_zh-CN.ini
  6. +2
    -1
      routers/api/v1/repo/cloudbrain_dashboard.go
  7. +0
    -4
      routers/user/auth.go
  8. +5
    -5
      templates/user/auth/signup_inner.tmpl
  9. +1
    -1
      web_src/js/index.js

+ 1
- 0
models/cloudbrain.go View File

@@ -30,6 +30,7 @@ const (
TypeCDCenter //成都智算中心 TypeCDCenter //成都智算中心


TypeCloudBrainAll = -1 TypeCloudBrainAll = -1
AccCardsNumAll = -1
) )


const ( const (


+ 8
- 0
models/user_analysis_for_activity.go View File

@@ -480,5 +480,13 @@ func QueryUserAnnualReport(userId int64) *UserSummaryCurrentYear {
} else { } else {
log.Info("error:=" + err.Error()) log.Info("error:=" + err.Error())
} }
dbuser, err := GetUserByID(userId)
if err == nil {
return &UserSummaryCurrentYear{
ID: dbuser.ID,
Name: dbuser.Name,
RegistDate: dbuser.CreatedUnix,
}
}
return nil return nil
} }

+ 17
- 7
models/user_business_analysis.go View File

@@ -887,12 +887,19 @@ func getBonusWeekDataMap() map[int64][]int {
if err == nil { if err == nil {
filenames := strings.Split(content, "\n") filenames := strings.Split(content, "\n")
for i := 0; i < len(filenames); i++ { for i := 0; i < len(filenames); i++ {
if strings.HasSuffix(filenames[i], "\r") {
filenames[i] = filenames[i][0 : len(filenames[i])-len("\r")]
}
url = setting.RecommentRepoAddr + "bonus/weekdata/" + filenames[i] url = setting.RecommentRepoAddr + "bonus/weekdata/" + filenames[i]
csvContent, err1 := GetContentFromPromote(url) csvContent, err1 := GetContentFromPromote(url)
if err1 == nil { if err1 == nil {
//read csv //read csv
lines := strings.Split(csvContent, "\n") lines := strings.Split(csvContent, "\n")
for j := 1; j < len(lines); j++ { for j := 1; j < len(lines); j++ {
if strings.HasSuffix(lines[j], "\r") {
lines[j] = lines[j][0 : len(lines[j])-len("\r")]
}
log.Info("aLine=" + lines[j])
aLine := strings.Split(lines[j], ",") aLine := strings.Split(lines[j], ",")
if len(aLine) < 4 { if len(aLine) < 4 {
continue continue
@@ -901,6 +908,7 @@ func getBonusWeekDataMap() map[int64][]int {
order := getIntValue(aLine[2]) order := getIntValue(aLine[2])
money := getIntValue(aLine[3]) money := getIntValue(aLine[3])
week, num := getWeekAndNum(filenames[i]) week, num := getWeekAndNum(filenames[i])
//log.Info("userId=" + fmt.Sprint(userId) + " order=" + fmt.Sprint(order) + " money=" + fmt.Sprint(money) + " week=" + fmt.Sprint(week) + " num=" + fmt.Sprint(num))
//email := lines[2] //email := lines[2]
record, ok := bonusMap[userId] record, ok := bonusMap[userId]
if !ok { if !ok {
@@ -949,12 +957,18 @@ func getBonusMap() map[string]map[string]int {
if err == nil { if err == nil {
filenames := strings.Split(content, "\n") filenames := strings.Split(content, "\n")
for i := 0; i < len(filenames); i++ { for i := 0; i < len(filenames); i++ {
if strings.HasSuffix(filenames[i], "\r") {
filenames[i] = filenames[i][0 : len(filenames[i])-len("\r")]
}
url = setting.RecommentRepoAddr + "bonus/" + filenames[i] url = setting.RecommentRepoAddr + "bonus/" + filenames[i]
csvContent, err1 := GetContentFromPromote(url) csvContent, err1 := GetContentFromPromote(url)
if err1 == nil { if err1 == nil {
//read csv //read csv
lines := strings.Split(csvContent, "\n") lines := strings.Split(csvContent, "\n")
for j := 1; j < len(lines); j++ { for j := 1; j < len(lines); j++ {
if strings.HasSuffix(lines[j], "\r") {
lines[j] = lines[j][0 : len(lines[j])-len("\r")]
}
aLine := strings.Split(lines[j], ",") aLine := strings.Split(lines[j], ",")
if len(aLine) < 7 { if len(aLine) < 7 {
continue continue
@@ -1030,18 +1044,14 @@ func getCloudBrainInfo(dateRecordAll UserBusinessAnalysisAll, CloudBrainTaskItem
} }
cloudBrainInfo["inference_task_num"] = fmt.Sprint(dateRecordAll.NpuInferenceJob + CloudBrainTaskItemMap[fmt.Sprint(dateRecordAll.ID)+"_GpuInferenceJob"]) cloudBrainInfo["inference_task_num"] = fmt.Sprint(dateRecordAll.NpuInferenceJob + CloudBrainTaskItemMap[fmt.Sprint(dateRecordAll.ID)+"_GpuInferenceJob"])
cloudBrainInfo["card_runtime"] = fmt.Sprint(dateRecordAll.CloudBrainRunTime) cloudBrainInfo["card_runtime"] = fmt.Sprint(dateRecordAll.CloudBrainRunTime)
if dateRecordAll.CloudBrainRunTime >= 100 {
runtime = float64(dateRecordAll.CloudBrainRunTime) / float64(100)
}
cloudBrainInfo["card_runtime_money"] = fmt.Sprint(dateRecordAll.CloudBrainRunTime * 5) cloudBrainInfo["card_runtime_money"] = fmt.Sprint(dateRecordAll.CloudBrainRunTime * 5)
cloudBrainInfo["CloudBrainOne"] = fmt.Sprint(CloudBrainTaskItemMap[fmt.Sprint(dateRecordAll.ID)+"_CloudBrainOne"]) cloudBrainInfo["CloudBrainOne"] = fmt.Sprint(CloudBrainTaskItemMap[fmt.Sprint(dateRecordAll.ID)+"_CloudBrainOne"])
cloudBrainInfo["CloudBrainTwo"] = fmt.Sprint(CloudBrainTaskItemMap[fmt.Sprint(dateRecordAll.ID)+"_CloudBrainTwo"]) cloudBrainInfo["CloudBrainTwo"] = fmt.Sprint(CloudBrainTaskItemMap[fmt.Sprint(dateRecordAll.ID)+"_CloudBrainTwo"])
cloudBrainInfo["C2Net"] = fmt.Sprint(CloudBrainTaskItemMap[fmt.Sprint(dateRecordAll.ID)+"_C2Net"]) cloudBrainInfo["C2Net"] = fmt.Sprint(CloudBrainTaskItemMap[fmt.Sprint(dateRecordAll.ID)+"_C2Net"])

cloudBrainInfoJson, _ := json.Marshal(cloudBrainInfo) cloudBrainInfoJson, _ := json.Marshal(cloudBrainInfo)
scoreMap["trainscore"] = trainscore scoreMap["trainscore"] = trainscore
scoreMap["debugscore"] = debugscore scoreMap["debugscore"] = debugscore
scoreMap["runtime"] = runtime
return string(cloudBrainInfoJson) return string(cloudBrainInfoJson)
} else { } else {
scoreMap["trainscore"] = trainscore scoreMap["trainscore"] = trainscore
@@ -2486,7 +2496,7 @@ func queryCloudBrainTask(start_unix int64, end_unix int64) (map[int64]int, map[s
var indexTotal int64 var indexTotal int64
indexTotal = 0 indexTotal = 0
for { for {
sess.Select("id,job_type,user_id,duration,train_job_duration,type").Table("cloudbrain").Unscoped().Where(cond).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal))
sess.Select("id,job_type,user_id,duration,train_job_duration,type,compute_resource").Table("cloudbrain").Unscoped().Where(cond).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal))
cloudTaskList := make([]*Cloudbrain, 0) cloudTaskList := make([]*Cloudbrain, 0)
sess.Find(&cloudTaskList) sess.Find(&cloudTaskList)
log.Info("query cloudbrain size=" + fmt.Sprint(len(cloudTaskList))) log.Info("query cloudbrain size=" + fmt.Sprint(len(cloudTaskList)))
@@ -2519,7 +2529,7 @@ func queryCloudBrainTask(start_unix int64, end_unix int64) (map[int64]int, map[s
} else { } else {
setMapKey("GpuDebugJob", cloudTaskRecord.UserID, 1, resultItemMap) setMapKey("GpuDebugJob", cloudTaskRecord.UserID, 1, resultItemMap)
} }
} else if cloudTaskRecord.Type == 2 {
} else if cloudTaskRecord.Type == 2 || cloudTaskRecord.Type == 3 {
setMapKey("C2Net", cloudTaskRecord.UserID, 1, resultItemMap) setMapKey("C2Net", cloudTaskRecord.UserID, 1, resultItemMap)
if cloudTaskRecord.ComputeResource == NPUResource { if cloudTaskRecord.ComputeResource == NPUResource {
if cloudTaskRecord.JobType == "TRAIN" { if cloudTaskRecord.JobType == "TRAIN" {


+ 6
- 1
modules/context/auth.go View File

@@ -81,7 +81,12 @@ func Toggle(options *ToggleOptions) macaron.Handler {


// Redirect to dashboard if user tries to visit any non-login page. // Redirect to dashboard if user tries to visit any non-login page.
if options.SignOutRequired && ctx.IsSigned && ctx.Req.URL.RequestURI() != "/" { if options.SignOutRequired && ctx.IsSigned && ctx.Req.URL.RequestURI() != "/" {
ctx.Redirect(setting.AppSubURL + "/")
redirectTo := ctx.Query("redirect_to")
if len(redirectTo) > 0 {
ctx.Redirect(redirectTo)
} else {
ctx.Redirect(setting.AppSubURL + "/")
}
return return
} }




+ 1
- 1
options/locale/locale_zh-CN.ini View File

@@ -73,7 +73,7 @@ your_starred=已点赞
your_settings=设置 your_settings=设置
invite_friends=邀请好友 invite_friends=邀请好友
your_friend=您的好友 your_friend=您的好友
invite_you_to_join_the_OpenI_AI_Collaboration_Platform_and_enjoy_abundant_free_computing_resources=邀请您加入启智社区AI协作平台,畅享充沛的免费算力资源!
invite_you_to_join_the_OpenI_AI_Collaboration_Platform_and_enjoy_abundant_free_computing_resources=邀请您加入启智社区AI协作平台,畅享充沛的普惠算力资源!
recommender=推荐人 recommender=推荐人


all=所有 all=所有


+ 2
- 1
routers/api/v1/repo/cloudbrain_dashboard.go View File

@@ -1260,8 +1260,8 @@ func DownloadCloudBrainBoard(ctx *context.Context) {
Type: models.TypeCloudBrainAll, Type: models.TypeCloudBrainAll,
BeginTimeUnix: int64(recordBeginTime), BeginTimeUnix: int64(recordBeginTime),
EndTimeUnix: endTime.Unix(), EndTimeUnix: endTime.Unix(),
AccCardsNum: models.AccCardsNumAll,
}) })
log.Info("totalcountisis:", total)


if err != nil { if err != nil {
log.Warn("Can not get cloud brain info", err) log.Warn("Can not get cloud brain info", err)
@@ -1290,6 +1290,7 @@ func DownloadCloudBrainBoard(ctx *context.Context) {
BeginTimeUnix: int64(recordBeginTime), BeginTimeUnix: int64(recordBeginTime),
EndTimeUnix: endTime.Unix(), EndTimeUnix: endTime.Unix(),
NeedRepoInfo: true, NeedRepoInfo: true,
AccCardsNum: models.AccCardsNumAll,
}) })
if err != nil { if err != nil {
log.Warn("Can not get cloud brain info", err) log.Warn("Can not get cloud brain info", err)


+ 0
- 4
routers/user/auth.go View File

@@ -121,7 +121,6 @@ func checkAutoLogin(ctx *context.Context) bool {
ctx.ServerError("AutoSignIn", err) ctx.ServerError("AutoSignIn", err)
return true return true
} }

redirectTo := ctx.Query("redirect_to") redirectTo := ctx.Query("redirect_to")
if len(redirectTo) > 0 { if len(redirectTo) > 0 {
ctx.SetCookie("redirect_to", redirectTo, 0, setting.AppSubURL, "", setting.SessionConfig.Secure, true) ctx.SetCookie("redirect_to", redirectTo, 0, setting.AppSubURL, "", setting.SessionConfig.Secure, true)
@@ -130,7 +129,6 @@ func checkAutoLogin(ctx *context.Context) bool {
} }


if isSucceed { if isSucceed {

isCourse := ctx.QueryBool("course") isCourse := ctx.QueryBool("course")
ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL, "", setting.SessionConfig.Secure, true) ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL, "", setting.SessionConfig.Secure, true)
if redirectTo == "" && isCourse { if redirectTo == "" && isCourse {
@@ -138,7 +136,6 @@ func checkAutoLogin(ctx *context.Context) bool {
ctx.RedirectToFirst(redirectToCourse) ctx.RedirectToFirst(redirectToCourse)
} else { } else {
ctx.RedirectToFirst(redirectTo, setting.AppSubURL+string(setting.LandingPageURL)) ctx.RedirectToFirst(redirectTo, setting.AppSubURL+string(setting.LandingPageURL))

} }
return true return true
} }
@@ -154,7 +151,6 @@ func getActivityTpl() string {
// SignIn render sign in page // SignIn render sign in page
func SignIn(ctx *context.Context) { func SignIn(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("sign_in") ctx.Data["Title"] = ctx.Tr("sign_in")

// Check auto-login. // Check auto-login.
if checkAutoLogin(ctx) { if checkAutoLogin(ctx) {
return return


+ 5
- 5
templates/user/auth/signup_inner.tmpl View File

@@ -163,11 +163,11 @@
return obj; return obj;
}; };
var sharedUser = getUrlParams()['sharedUser']; var sharedUser = getUrlParams()['sharedUser'];
if (sharedUser) {
setTimeout(function() {
$('.invitation_tips').show().find('.__invitation_code__').text(sharedUser);
$('input#invitation_code').val(sharedUser).attr('readonly', true);
}, 20);
if (sharedUser) {
document.querySelector('.invitation_tips').style.display = "block";
document.querySelector('.__invitation_code__').innerText = sharedUser;
document.querySelector('#invitation_code').value = sharedUser;
document.querySelector('#invitation_code').setAttribute("readonly", "true");
} }
})(); })();
</script> </script>

+ 1
- 1
web_src/js/index.js View File

@@ -5221,7 +5221,7 @@ function initTopToHome() {
} }
}); });
topToHomeEl.on('click', function() { topToHomeEl.on('click', function() {
$('html').animate({ scrollTop: 0 }, 'slow', 'swing');
$('html,body').animate({ scrollTop: 0 }, 'slow', 'swing');
}); });
} }




Loading…
Cancel
Save