diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 5be07f741..4f615ed00 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -65,6 +65,11 @@ type Cloudbrain struct { Repo *Repository `xorm:"-"` } +type CloudbrainInfo struct { + Cloudbrain `xorm:"extends"` + User `xorm:"extends"` +} + type CloudBrainLoginResult struct { Code string Msg string @@ -523,7 +528,7 @@ type NotebookDelResult struct { InstanceID string `json:"instance_id"` } -func Cloudbrains(opts *CloudbrainsOptions) ([]*Cloudbrain, int64, error) { +func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { sess := x.NewSession() defer sess.Close() @@ -583,8 +588,10 @@ func Cloudbrains(opts *CloudbrainsOptions) ([]*Cloudbrain, int64, error) { } sess.OrderBy("cloudbrain.created_unix DESC") - cloudbrains := make([]*Cloudbrain, 0, setting.UI.IssuePagingNum) - if err := sess.Where(cond).Find(&cloudbrains); err != nil { + cloudbrains := make([]*CloudbrainInfo, 0, setting.UI.IssuePagingNum) + if err := sess.Table(&Cloudbrain{}).Where(cond). + Join("left", "`user`", "cloudbrain.user_id = `user`.id"). + Find(&cloudbrains); err != nil { return nil, 0, fmt.Errorf("Find: %v", err) } sess.Close() diff --git a/modules/git/repo_stats_custom.go b/modules/git/repo_stats_custom.go index 95f1086ad..50a740fb0 100644 --- a/modules/git/repo_stats_custom.go +++ b/modules/git/repo_stats_custom.go @@ -13,6 +13,7 @@ import ( type RepoKPIStats struct { Contributors int64 KeyContributors int64 + DevelopAge int64 ContributorsAdded int64 CommitsAdded int64 CommitLinesModified int64 @@ -66,6 +67,10 @@ func GetRepoKPIStats(repoPath string) (*RepoKPIStats, error) { } + err = setDevelopAge(repoPath, stats) + if err != nil { + return nil, fmt.Errorf("FillFromGit: %v", err) + } err = setRepoKPIStats(repoPath, fourMonthAgo, stats, newContributersDict) if err != nil { @@ -75,6 +80,27 @@ func GetRepoKPIStats(repoPath string) (*RepoKPIStats, error) { } +func setDevelopAge(repoPath string, stats *RepoKPIStats) error { + args := []string{"log", "--no-merges", "--branches=*", "--format=%cd", "--date=short"} + stdout, err := NewCommand(args...).RunInDirBytes(repoPath) + if err != nil { + return err + } + scanner := bufio.NewScanner(bytes.NewReader(stdout)) + scanner.Split(bufio.ScanLines) + developMonth := make(map[string]struct{}) + for scanner.Scan() { + l := strings.TrimSpace(scanner.Text()) + month := l[0:strings.LastIndex(l, "-")] + if _, ok := developMonth[month]; !ok { + developMonth[month] = struct{}{} + } + } + + stats.DevelopAge = int64(len(developMonth)) + return nil +} + //获取一天内的用户贡献指标 func GetUserKPIStats(repoPath string) (map[string]*UserKPIStats, error) { timeUntil := time.Now() diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 7a39eb1b5..bf7be287d 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -573,7 +573,7 @@ authorized_oauth2_applications_description = You've granted access to your perso revoke_key = Revoke revoke_oauth2_grant = Revoke Access revoke_oauth2_grant_description = Revoking access for this third party application will prevent this application from accessing your data. Are you sure? -revoke_oauth2_grant_success = You've revoked access successfully. +revoke_oauth2_grant_success = You have revoked access successfully. twofa_desc = Two-factor authentication enhances the security of your account. twofa_is_enrolled = Your account is currently enrolled in two-factor authentication. @@ -770,6 +770,7 @@ cloudbrain_selection = select cloudbrain cloudbrain_platform_selection = Select the cloudbrain platform you want to use: confirm_choice = confirm cloudbran1_tips = Only data in zip format can create cloudbrain tasks +cloudbrain_creator=Creator template.items = Template Items template.git_content = Git Content (Default Branch) diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 12de2090b..04b3c2e59 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -772,6 +772,7 @@ cloudbrain_selection=云脑选择 cloudbrain_platform_selection=选择您准备使用的云脑平台: confirm_choice=确定 cloudbran1_tips=只有zip格式的数据集才能发起云脑任务 +cloudbrain_creator=创建者 template.items=模板选项 template.git_content=Git数据(默认分支) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index c30906af4..ccd51a89f 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -69,7 +69,8 @@ func CloudBrainIndex(ctx *context.Context) { timestamp := time.Now().Unix() for i, task := range ciTasks { - if task.Status == string(models.JobRunning) && (timestamp-int64(task.CreatedUnix) > 10) { + log.Info("", task.User.Name) + if task.Status == string(models.JobRunning) && (timestamp-int64(task.Cloudbrain.CreatedUnix) > 10) { ciTasks[i].CanDebug = true } else { ciTasks[i].CanDebug = false diff --git a/templates/explore/dataset_search.tmpl b/templates/explore/dataset_search.tmpl index 6c973026a..aad8f5083 100644 --- a/templates/explore/dataset_search.tmpl +++ b/templates/explore/dataset_search.tmpl @@ -1,12 +1,12 @@
-
+
- +
diff --git a/templates/explore/search.tmpl b/templates/explore/search.tmpl index 11e89d50a..4353f7302 100644 --- a/templates/explore/search.tmpl +++ b/templates/explore/search.tmpl @@ -1,11 +1,11 @@
-
+
- +
diff --git a/templates/repo/cloudbrain/index.tmpl b/templates/repo/cloudbrain/index.tmpl index 0a75db9de..f39e0605a 100755 --- a/templates/repo/cloudbrain/index.tmpl +++ b/templates/repo/cloudbrain/index.tmpl @@ -262,10 +262,10 @@
-
- + @@ -285,10 +285,14 @@ {{end}} - {{TimeSinceUnix .CreatedUnix $.Lang}} + {{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}}
-
+
+ {{$.i18n.Tr "repo.cloudbrain_creator"}}{{.User.Name}} + +
+ diff --git a/templates/repo/issue/labels.tmpl b/templates/repo/issue/labels.tmpl index d3df3b594..36683ca9b 100644 --- a/templates/repo/issue/labels.tmpl +++ b/templates/repo/issue/labels.tmpl @@ -2,14 +2,24 @@
{{template "repo/header" .}}
- +
+
+ +
+
+ {{template "repo/issue/navbar" .}} + {{if and (or .CanWriteIssues .CanWritePulls) (not .Repository.IsArchived)}} +
+
{{.i18n.Tr "repo.issues.new_label"}}
+
+ {{end}} +
+ +
{{if and (or .CanWriteIssues .CanWritePulls) (not .Repository.IsArchived)}} {{template "repo/issue/labels/label_new" .}} diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index f64de74e8..a99205eea 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -3,14 +3,19 @@ {{template "repo/header" .}}
-
- {{template "repo/issue/navbar" .}} +
{{template "repo/issue/search" .}}
{{if not .Repository.IsArchived}}
+ {{template "repo/issue/navbar" .}} {{if .PageIsIssueList}} {{.i18n.Tr "repo.issues.new"}} {{else}} diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index a35dacbce..b8f68e025 100755 --- a/templates/repo/issue/milestone_issues.tmpl +++ b/templates/repo/issue/milestone_issues.tmpl @@ -3,8 +3,14 @@ {{template "repo/header" .}}
-
-

{{.Milestone.Name}}

+
+
diff --git a/templates/repo/issue/milestone_new.tmpl b/templates/repo/issue/milestone_new.tmpl index ea704c056..6f17f1b71 100644 --- a/templates/repo/issue/milestone_new.tmpl +++ b/templates/repo/issue/milestone_new.tmpl @@ -2,13 +2,29 @@
{{template "repo/header" .}}
-