| @@ -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) | |||
| @@ -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) | |||
| @@ -432,6 +432,7 @@ | |||
| // 加载任务状态 | |||
| var timeid = window.setInterval(loadJobStatus, 15000); | |||
| $(document).ready(loadJobStatus); | |||
| function loadJobStatus() { | |||
| $(".job-status").each((index, job) => { | |||
| const jobID = job.dataset.jobid; | |||
| @@ -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" | |||
| @@ -30,24 +30,33 @@ | |||
| <a class="ui text center" href="datasets/label/{{.UUID}}?type={{$.Type}}" data-tooltip='{{$.i18n.Tr "dataset.create_label_task"}}'><i class="fa fa-pencil-square-o" aria-hidden="true"></i></a> | |||
| </div> | |||
| {{end}} | |||
| {{if $.Permission.CanWrite $.UnitTypeDatasets}} | |||
| {{if (not .CanDel) or $.Repository.IsPrivate}} | |||
| <div class="two wide column"> | |||
| <a class="ui button mini" disabled='true' data-tooltip='{{$.i18n.Tr "dataset.how_to_public"}}'>{{$.i18n.Tr "dataset.private"}}</a> | |||
| {{if not .CanDel}} | |||
| <div class="two wide column"> | |||
| <a class="ui button mini" disabled='true'>{{if .IsPrivate}} {{$.i18n.Tr "dataset.private"}} {{else}} {{$.i18n.Tr "dataset.public"}} {{end}}</a> | |||
| </div> | |||
| {{else}} | |||
| {{if $.Permission.CanWrite $.UnitTypeDatasets}} | |||
| {{if $.Repository.IsPrivate}} | |||
| <div class="two wide column"> | |||
| <a class="ui button mini" disabled='true' data-tooltip='{{$.i18n.Tr "dataset.how_to_public"}}'>{{$.i18n.Tr "dataset.private"}}</a> | |||
| </div> | |||
| {{ else }} | |||
| <div class="two wide column"> | |||
| <div class="ui buttons mini"> | |||
| <a class="ui button mini {{if .IsPrivate}}positive active{{end}}" href="javascript:void(0)" data-dataset-status="true-{{.UUID}}" data-csrf="{{$.CsrfToken}}" data-url="{{AppSubUrl}}/attachments/private" data-uuid={{.UUID}} data-private="true" data-is-private={{.IsPrivate}}>{{$.i18n.Tr "dataset.private"}}</a> | |||
| <div class="or"></div> | |||
| <a class="ui button mini {{if not .IsPrivate}}positive active{{end}}" href="javascript:void(0)" data-dataset-status="false-{{.UUID}}" data-csrf="{{$.CsrfToken}}" data-url="{{AppSubUrl}}/attachments/private" data-uuid={{.UUID}} data-private="false" data-is-private={{.IsPrivate}}>{{$.i18n.Tr "dataset.public"}}</a> | |||
| </div> | |||
| </div> | |||
| {{end}} | |||
| <div class="two wide column right aligned"> | |||
| <a class="ui red button mini" href="javascript:void(0)" data-uuid={{.UUID}} data-dataset-delete data-remove-url="{{AppSubUrl}}/attachments/delete" data-csrf="{{$.CsrfToken}}">{{$.i18n.Tr "dataset.delete"}}</a> | |||
| </div> | |||
| {{ else }} | |||
| {{else}} | |||
| <div class="two wide column"> | |||
| <div class="ui buttons mini"> | |||
| <a class="ui button mini {{if .IsPrivate}}positive active{{end}}" href="javascript:void(0)" data-dataset-status="true-{{.UUID}}" data-csrf="{{$.CsrfToken}}" data-url="{{AppSubUrl}}/attachments/private" data-uuid={{.UUID}} data-private="true" data-is-private={{.IsPrivate}}>{{$.i18n.Tr "dataset.private"}}</a> | |||
| <div class="or"></div> | |||
| <a class="ui button mini {{if not .IsPrivate}}positive active{{end}}" href="javascript:void(0)" data-dataset-status="false-{{.UUID}}" data-csrf="{{$.CsrfToken}}" data-url="{{AppSubUrl}}/attachments/private" data-uuid={{.UUID}} data-private="false" data-is-private={{.IsPrivate}}>{{$.i18n.Tr "dataset.public"}}</a> | |||
| </div> | |||
| <a class="ui button mini" disabled='true'>{{if .IsPrivate}} {{$.i18n.Tr "dataset.private"}} {{else}} {{$.i18n.Tr "dataset.public"}} {{end}}</a> | |||
| </div> | |||
| {{end}} | |||
| <div class="two wide column right aligned" style="{{if not .CanDel}}visibility: hidden;{{end}}"> | |||
| <a class="ui red button mini" href="javascript:void(0)" data-uuid={{.UUID}} data-dataset-delete data-remove-url="{{AppSubUrl}}/attachments/delete" data-csrf="{{$.CsrfToken}}">{{$.i18n.Tr "dataset.delete"}}</a> | |||
| </div> | |||
| {{end}} | |||
| </div> | |||
| </div> | |||
| @@ -405,6 +405,7 @@ | |||
| // 加载任务状态 | |||
| var timeid = window.setInterval(loadJobStatus, 15000); | |||
| $(document).ready(loadJobStatus); | |||
| function loadJobStatus() { | |||
| $(".job-status").each((index, job) => { | |||
| const jobID = job.dataset.jobid; | |||
| @@ -120,7 +120,7 @@ | |||
| <input type="text" list="cloudbrain_dataset" placeholder="选择数据集" name="" id="answerInput" autofocus maxlength="36"> | |||
| <datalist id="cloudbrain_dataset" class="ui search" style='width:385px' name="attachment"> | |||
| {{range .attachments}} | |||
| <option name="attachment" value="{{.UUID}}">{{.Attachment.Name}}</option> | |||
| <option name="attachment" data-value="{{.UUID}}">{{.Attachment.Name}}</option> | |||
| {{end}} | |||
| </datalist> | |||
| <input type="hidden" name="attachment" id="answerInput-hidden"> | |||