diff --git a/models/user.go b/models/user.go index 83bf1b2c0..38f699740 100755 --- a/models/user.go +++ b/models/user.go @@ -1543,6 +1543,22 @@ func ValidateCommitsWithEmails(oldCommits *list.List) *list.List { return newCommits } +// GetUserByActivateEmail returns the user object by given e-mail if exists. +/*This function will search email table only*/ +func GetUserByActivateEmail(email string) (*User, error) { + ctx := DefaultDBContext() + var users []User + if err := ctx.e.Join("INNER", "email_address", "email_address.uid = \"user\".id"). + Where("email_address.email= ?", email). + Find(&users); err != nil { + return nil,err + } + if len(users) >= 1 { + return &users[0],nil + }else { + return nil, errors.New("cannot find user by email") + } +} // GetUserByEmail returns the user object by given e-mail if exists. func GetUserByEmail(email string) (*User, error) { return GetUserByEmailContext(DefaultDBContext(), email) diff --git a/routers/repo/view.go b/routers/repo/view.go index 1ee47e12e..1546f53b7 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -15,6 +15,7 @@ import ( "net/url" "path" "strings" + "time" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" @@ -588,39 +589,45 @@ func Home(ctx *context.Context) { //get repo contributors info contributors, err := git.GetContributors(ctx.Repo.Repository.RepoPath()) if err == nil && contributors != nil { + startTime := time.Now() var contributorInfos []*ContributorInfo + contributorInfoHash:= make(map[string]*ContributorInfo) for _, c := range contributors { if strings.Compare(c.Email,"") == 0 { continue } // get user info from committer email - user, err := models.GetUserByEmail(c.Email) + user, err := models.GetUserByActivateEmail(c.Email) if err == nil { // committer is system user, get info through user's primary email - existedContributorInfo := getContributorInfo(contributorInfos,user.Email) - if existedContributorInfo != nil { + if existedContributorInfo,ok:=contributorInfoHash[user.Email];ok { // existed: same primary email, different committer name existedContributorInfo.CommitCnt += c.CommitCnt }else{ // new committer info - contributorInfos = append(contributorInfos, &ContributorInfo{ + var newContributor = &ContributorInfo{ user, user.Email,c.CommitCnt, - }) + } + contributorInfos = append(contributorInfos, newContributor ) + contributorInfoHash[user.Email] = newContributor } } else { // committer is not system user - existedContributorInfo := getContributorInfo(contributorInfos,c.Email) - if existedContributorInfo != nil { + if existedContributorInfo,ok:=contributorInfoHash[c.Email];ok { // existed: same primary email, different committer name existedContributorInfo.CommitCnt += c.CommitCnt }else{ - contributorInfos = append(contributorInfos, &ContributorInfo{ - nil, c.Email,c.CommitCnt, - }) + var newContributor = &ContributorInfo{ + user, c.Email,c.CommitCnt, + } + contributorInfos = append(contributorInfos, newContributor) + contributorInfoHash[c.Email] = newContributor } } } ctx.Data["ContributorInfo"] = contributorInfos + var duration = time.Since(startTime) + log.Info("getContributorInfo cost: %v seconds",duration.Seconds()) } if ctx.Repo.Repository.IsBeingCreated() { task, err := models.GetMigratingTask(ctx.Repo.Repository.ID) diff --git a/templates/repo/cloudbrain/index.tmpl b/templates/repo/cloudbrain/index.tmpl index acb87b74b..a477d2a83 100755 --- a/templates/repo/cloudbrain/index.tmpl +++ b/templates/repo/cloudbrain/index.tmpl @@ -434,6 +434,7 @@ // 加载任务状态 var timeid = window.setInterval(loadJobStatus, 15000); + $(document).ready(loadJobStatus); function loadJobStatus() { $(".job-status").each((index, job) => { const jobID = job.dataset.jobid; diff --git a/templates/repo/cloudbrain/new.tmpl b/templates/repo/cloudbrain/new.tmpl index 2e098f862..c45776b89 100755 --- a/templates/repo/cloudbrain/new.tmpl +++ b/templates/repo/cloudbrain/new.tmpl @@ -258,9 +258,10 @@ $('#messageInfo p').text(str) return false } - if(!value_image || !value_data){ - return false - } + // if(!value_image || !value_data){ + // console.log("------------------------") + // return false + // } let min_value_task = value_task.toLowerCase() $("input[name='job_name']").attr("value",min_value_task) document.getElementById("mask").style.display = "block" diff --git a/templates/repo/datasets/dataset_list.tmpl b/templates/repo/datasets/dataset_list.tmpl index 639028d65..cf6c47926 100755 --- a/templates/repo/datasets/dataset_list.tmpl +++ b/templates/repo/datasets/dataset_list.tmpl @@ -30,24 +30,33 @@ {{end}} - {{if $.Permission.CanWrite $.UnitTypeDatasets}} - {{if (not .CanDel) or $.Repository.IsPrivate}} -
- {{$.i18n.Tr "dataset.private"}} + {{if not .CanDel}} +
+ {{if .IsPrivate}} {{$.i18n.Tr "dataset.private"}} {{else}} {{$.i18n.Tr "dataset.public"}} {{end}} +
+ {{else}} + {{if $.Permission.CanWrite $.UnitTypeDatasets}} + {{if $.Repository.IsPrivate}} +
+ {{$.i18n.Tr "dataset.private"}} +
+ {{ else }} +
+ +
+ {{end}} +
+ {{$.i18n.Tr "dataset.delete"}}
- {{ else }} + {{else}}
- + {{if .IsPrivate}} {{$.i18n.Tr "dataset.private"}} {{else}} {{$.i18n.Tr "dataset.public"}} {{end}}
{{end}} - -
- {{$.i18n.Tr "dataset.delete"}} -
{{end}}
diff --git a/templates/repo/modelarts/index.tmpl b/templates/repo/modelarts/index.tmpl index 838b24eef..a42f502d8 100755 --- a/templates/repo/modelarts/index.tmpl +++ b/templates/repo/modelarts/index.tmpl @@ -371,6 +371,7 @@ // 加载任务状态 var timeid = window.setInterval(loadJobStatus, 15000); + $(document).ready(loadJobStatus); function loadJobStatus() { $(".job-status").each((index, job) => { const jobID = job.dataset.jobid; diff --git a/templates/repo/modelarts/new.tmpl b/templates/repo/modelarts/new.tmpl index fd42670a1..8cfa680f7 100755 --- a/templates/repo/modelarts/new.tmpl +++ b/templates/repo/modelarts/new.tmpl @@ -120,7 +120,7 @@ {{range .attachments}} - + {{end}}