@@ -1102,3 +1102,41 @@ PROJECT_NAME = cn-south-222_test | |||
USERNAME = test1 | |||
PASSWORD = Qizhi@test. | |||
DOMAIN = cn-south-222 | |||
[radar_map] | |||
impact=0.3 | |||
impact_watch=0.1 | |||
impact_star=0.3 | |||
impact_fork=0.3 | |||
impact_code_download=0.2 | |||
impact_comments=0.1 | |||
impact_browser=0.1 | |||
completeness=0.1 | |||
completeness_issues_closed=0.2 | |||
completeness_releases=0.3 | |||
completeness_develop_age=0.1 | |||
completeness_dataset=0.1 | |||
completeness_model=0.1 | |||
completeness_wiki=0.1 | |||
liveness=0.3 | |||
liveness_commit=0.2 | |||
liveness_issue=0.2 | |||
liveness_pr=0.2 | |||
liveness_release=0.4 | |||
project_health=0.1 | |||
project_health_issue_complete_ratio=100 | |||
team_health=0.1 | |||
team_health_contributors=0.2 | |||
team_health_key_contributors=0.6 | |||
team_health_contributors_added=0.2 | |||
growth=0.1 | |||
growth_code_lines=0.2 | |||
growth_issue=0.2 | |||
growth_contributors=0.2 | |||
growth_commit=0.2 | |||
growth_comments=0.2 |
@@ -1,38 +1,62 @@ | |||
package models | |||
import ( | |||
"code.gitea.io/gitea/modules/timeutil" | |||
"fmt" | |||
"time" | |||
"code.gitea.io/gitea/modules/timeutil" | |||
) | |||
// RepoStatistic statistic info of all repository | |||
type RepoStatistic struct { | |||
ID int64 `xorm:"pk autoincr"` | |||
RepoID int64 `xorm:"unique(s) NOT NULL"` | |||
Date string `xorm:"unique(s) NOT NULL"` | |||
NumWatches int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumStars int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumForks int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumDownloads int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumComments int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumVisits int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumClosedIssues int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumVersions int64 `xorm:"NOT NULL DEFAULT 0"` | |||
//develop months | |||
NumDevMonths int64 `xorm:"NOT NULL DEFAULT 0"` | |||
RepoSize int64 `xorm:"NOT NULL DEFAULT 0"` | |||
DatasetSize int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumModels int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumWikiViews int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumCommits int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumIssues int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumPulls int64 `xorm:"NOT NULL DEFAULT 0"` | |||
IssueFixedRate float32 `xorm:"NOT NULL"` | |||
NumContributor int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumKeyContributor int64 `xorm:"NOT NULL DEFAULT 0"` | |||
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` | |||
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` | |||
ID int64 `xorm:"pk autoincr"` | |||
RepoID int64 `xorm:"unique(s) NOT NULL"` | |||
Date string `xorm:"unique(s) NOT NULL"` | |||
NumWatches int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumWatchesAdded int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumStars int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumStarsAdded int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumForks int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumForksAdded int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumDownloads int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumDownloadsAdded int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumComments int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumCommentsAdded int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumVisits int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumClosedIssues int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumClosedIssuesAdded int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumVersions int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumDevMonths int64 `xorm:"NOT NULL DEFAULT 0"` | |||
RepoSize int64 `xorm:"NOT NULL DEFAULT 0"` | |||
DatasetSize int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumModels int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumWikiViews int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumCommits int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumCommitsAdded int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumIssues int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumIssuesAdded int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumPulls int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumPullsAdded int64 `xorm:"NOT NULL DEFAULT 0"` | |||
IssueFixedRate float32 `xorm:"NOT NULL"` | |||
NumContributor int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumContributorAdded int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumKeyContributor int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumContributorsGrowth int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumCommitsGrowth int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumCommitLinesGrowth int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumIssuesGrowth int64 `xorm:"NOT NULL DEFAULT 0"` | |||
NumCommentsGrowth int64 `xorm:"NOT NULL DEFAULT 0"` | |||
Impact float64 `xorm:"NOT NULL DEFAULT 0"` | |||
Completeness float64 `xorm:"NOT NULL DEFAULT 0"` | |||
Liveness float64 `xorm:"NOT NULL DEFAULT 0"` | |||
ProjectHealth float64 `xorm:"NOT NULL DEFAULT 0"` | |||
TeamHealth float64 `xorm:"NOT NULL DEFAULT 0"` | |||
Growth float64 `xorm:"NOT NULL DEFAULT 0"` | |||
RadarTotal float64 `xorm:"NOT NULL DEFAULT 0"` | |||
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` | |||
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` | |||
} | |||
func DeleteRepoStatDaily(date string) error { | |||
@@ -55,6 +79,35 @@ func DeleteRepoStatDaily(date string) error { | |||
return nil | |||
} | |||
func GetRepoStatisticByDate(date string) ([]*RepoStatistic, error) { | |||
repoStatistics := make([]*RepoStatistic, 0) | |||
err := xStatistic.Where("date = ?", date).Find(&repoStatistics) | |||
return repoStatistics, err | |||
} | |||
func GetOneRepoStatisticBeforeTime(time time.Time) (*RepoStatistic, error) { | |||
repoStatistics := make([]*RepoStatistic, 0) | |||
err := xStatistic.Where("created_unix >= ?", time.Unix()).OrderBy("created_unix").Limit(1).Find(&repoStatistics) | |||
if err != nil { | |||
return nil, err | |||
} else { | |||
if len(repoStatistics) == 0 { | |||
return nil, fmt.Errorf("the repo statistic record count is 0") | |||
} else { | |||
return repoStatistics[0], nil | |||
} | |||
} | |||
} | |||
func InsertRepoStat(repoStat *RepoStatistic) (int64, error) { | |||
return xStatistic.Insert(repoStat) | |||
} | |||
func UpdateRepoStat(repoStat *RepoStatistic) error { | |||
sql := "update repo_statistic set impact=?,completeness=?,liveness=?,project_health=?,team_health=?,growth=?,radar_total=? where repo_id=? and date=?" | |||
_, err := xStatistic.Exec(sql, repoStat.Impact, repoStat.Completeness, repoStat.Liveness, repoStat.ProjectHealth, repoStat.TeamHealth, repoStat.Growth, repoStat.RadarTotal, repoStat.RepoID, repoStat.Date) | |||
return err | |||
} |
@@ -310,9 +310,11 @@ func Contexter() macaron.Handler { | |||
ctx.Data["SignedUserID"] = ctx.User.ID | |||
ctx.Data["SignedUserName"] = ctx.User.Name | |||
ctx.Data["IsAdmin"] = ctx.User.IsAdmin | |||
c.Data["SignedUserName"] = ctx.User.Name | |||
} else { | |||
ctx.Data["SignedUserID"] = int64(0) | |||
ctx.Data["SignedUserName"] = "" | |||
c.Data["SignedUserName"] = "" | |||
} | |||
// If request sends files, parse them here otherwise the Query() can't be parsed and the CsrfToken will be invalid. | |||
@@ -0,0 +1,83 @@ | |||
package normalization | |||
import ( | |||
"code.gitea.io/gitea/modules/setting" | |||
) | |||
func Normalization(value float64, minValue float64, maxValue float64) float64 { | |||
min := int64(minValue * 100) | |||
max := int64(maxValue * 100) | |||
if min == max { | |||
return 100.0 | |||
} else { | |||
return 100 * (value - minValue) / (maxValue - minValue) | |||
} | |||
} | |||
func GetRadarValue(impactValue float64, completeValue float64, livenessValue float64, projectHealthValue float64, teamHealthValue float64, growthValue float64) float64 { | |||
return setting.RadarMap.Impact*impactValue + | |||
setting.RadarMap.Completeness*completeValue + | |||
setting.RadarMap.Liveness*livenessValue + | |||
setting.RadarMap.ProjectHealth*projectHealthValue + | |||
setting.RadarMap.TeamHealth*teamHealthValue + | |||
setting.RadarMap.Growth*growthValue | |||
} | |||
func GetImpactInitValue(watch int64, star int64, fork int64, download int64, comments int64, browser int64) float64 { | |||
return setting.RadarMap.ImpactWatch*float64(watch) + | |||
setting.RadarMap.ImpactStar*float64(star) + | |||
setting.RadarMap.ImpactFork*float64(fork) + | |||
setting.RadarMap.ImpactCodeDownload*float64(download)*0.001 + | |||
setting.RadarMap.ImpactComments*float64(comments) + | |||
setting.RadarMap.ImpactBrowser*float64(browser) | |||
} | |||
func GetCompleteInitValue(issuesClosed int64, releases int64, developAge int64, dataset int64, model int64, wiki int64) float64 { | |||
return setting.RadarMap.CompletenessIssuesClosed*float64(issuesClosed) + | |||
setting.RadarMap.CompletenessReleases*float64(releases) + | |||
setting.RadarMap.CompletenessDevelopAge*float64(developAge) + | |||
setting.RadarMap.CompletenessDataset*float64(dataset/(1024*1024)) + | |||
setting.RadarMap.CompletenessModel*float64(model) + | |||
setting.RadarMap.CompletenessWiki*float64(wiki) | |||
} | |||
func GetLivenessInitValue(commits int64, issues int64, pr int64, release int64) float64 { | |||
return setting.RadarMap.LivenessCommit*float64(commits) + | |||
setting.RadarMap.LivenessIssue*float64(issues) + | |||
setting.RadarMap.LivenessPR*float64(pr) + | |||
setting.RadarMap.LivenessRelease*float64(release) | |||
} | |||
func GetProjectHealthInitValue(issueClosedRatio float32) float64 { | |||
return setting.RadarMap.ProjectHealthIssueCompleteRatio * float64(issueClosedRatio) | |||
} | |||
func GetTeamHealthInitValue(contributors int64, keyContributors int64, newContributors int64) float64 { | |||
return setting.RadarMap.TeamHealthContributors*float64(contributors) + | |||
setting.RadarMap.TeamHealthKeyContributors*float64(keyContributors) + | |||
setting.RadarMap.TeamHealthContributorsAdded*float64(newContributors) | |||
} | |||
func GetRepoGrowthInitValue(codelinesGrowth int64, issueGrowth int64, commitsGrowth int64, newContributors int64, commentsGrowth int64) float64 { | |||
return setting.RadarMap.GrowthCodeLines*float64(codelinesGrowth) + | |||
setting.RadarMap.GrowthIssue*float64(issueGrowth) + | |||
setting.RadarMap.GrowthCommit*float64(commitsGrowth) + | |||
setting.RadarMap.GrowthContributors*float64(newContributors) + | |||
setting.RadarMap.GrowthComments*float64(commentsGrowth) | |||
} |
@@ -498,6 +498,44 @@ var ( | |||
//nginx proxy | |||
PROXYURL string | |||
RadarMap = struct { | |||
Impact float64 | |||
ImpactWatch float64 | |||
ImpactStar float64 | |||
ImpactFork float64 | |||
ImpactCodeDownload float64 | |||
ImpactComments float64 | |||
ImpactBrowser float64 | |||
Completeness float64 | |||
CompletenessIssuesClosed float64 | |||
CompletenessReleases float64 | |||
CompletenessDevelopAge float64 | |||
CompletenessDataset float64 | |||
CompletenessModel float64 | |||
CompletenessWiki float64 | |||
Liveness float64 | |||
LivenessCommit float64 | |||
LivenessIssue float64 | |||
LivenessPR float64 | |||
LivenessRelease float64 | |||
ProjectHealth float64 | |||
ProjectHealthIssueCompleteRatio float64 | |||
TeamHealth float64 | |||
TeamHealthContributors float64 | |||
TeamHealthKeyContributors float64 | |||
TeamHealthContributorsAdded float64 | |||
Growth float64 | |||
GrowthCodeLines float64 | |||
GrowthIssue float64 | |||
GrowthContributors float64 | |||
GrowthCommit float64 | |||
GrowthComments float64 | |||
}{} | |||
) | |||
// DateLang transforms standard language locale name to corresponding value in datetime plugin. | |||
@@ -1232,6 +1270,40 @@ func NewContext() { | |||
TimeField = sec.Key("TIMEFIELD").MustString(" @timestamptest") | |||
ElkTimeFormat = sec.Key("ELKTIMEFORMAT").MustString("date_time") | |||
sec = Cfg.Section("radar_map") | |||
RadarMap.Impact = sec.Key("impact").MustFloat64(0.3) | |||
RadarMap.ImpactWatch = sec.Key("impact_watch").MustFloat64(0.1) | |||
RadarMap.ImpactStar = sec.Key("impact_star").MustFloat64(0.3) | |||
RadarMap.ImpactFork = sec.Key("impact_fork").MustFloat64(0.3) | |||
RadarMap.ImpactCodeDownload = sec.Key("impact_code_download").MustFloat64(0.2) | |||
RadarMap.ImpactComments = sec.Key("impact_comments").MustFloat64(0.1) | |||
RadarMap.ImpactBrowser = sec.Key("impact_browser").MustFloat64(0.1) | |||
RadarMap.Completeness = sec.Key("completeness").MustFloat64(0.1) | |||
RadarMap.CompletenessIssuesClosed = sec.Key("completeness_issues_closed").MustFloat64(0.2) | |||
RadarMap.CompletenessReleases = sec.Key("completeness_releases").MustFloat64(0.3) | |||
RadarMap.CompletenessDevelopAge = sec.Key("completeness_develop_age").MustFloat64(0.1) | |||
RadarMap.CompletenessDataset = sec.Key("completeness_dataset").MustFloat64(0.1) | |||
RadarMap.CompletenessModel = sec.Key("completeness_model").MustFloat64(0.1) | |||
RadarMap.CompletenessWiki = sec.Key("completeness_wiki").MustFloat64(0.1) | |||
RadarMap.Liveness = sec.Key("liveness").MustFloat64(0.3) | |||
RadarMap.LivenessCommit = sec.Key("liveness_commit").MustFloat64(0.2) | |||
RadarMap.LivenessIssue = sec.Key("liveness_issue").MustFloat64(0.2) | |||
RadarMap.LivenessPR = sec.Key("liveness_pr").MustFloat64(0.2) | |||
RadarMap.LivenessRelease = sec.Key("liveness_release").MustFloat64(0.4) | |||
RadarMap.ProjectHealth = sec.Key("project_health").MustFloat64(0.1) | |||
RadarMap.ProjectHealthIssueCompleteRatio = sec.Key("project_health_issue_complete_ratio").MustFloat64(100) | |||
RadarMap.TeamHealth = sec.Key("team_health").MustFloat64(0.1) | |||
RadarMap.TeamHealthContributors = sec.Key("team_health_contributors").MustFloat64(0.2) | |||
RadarMap.TeamHealthKeyContributors = sec.Key("team_health_key_contributors").MustFloat64(0.6) | |||
RadarMap.TeamHealthContributorsAdded = sec.Key("team_health_contributors_added").MustFloat64(0.2) | |||
RadarMap.Growth = sec.Key("growth").MustFloat64(0.1) | |||
RadarMap.GrowthCodeLines = sec.Key("growth_code_lines").MustFloat64(0.2) | |||
RadarMap.GrowthIssue = sec.Key("growth_issue").MustFloat64(0.2) | |||
RadarMap.GrowthContributors = sec.Key("growth_contributors").MustFloat64(0.2) | |||
RadarMap.GrowthCommit = sec.Key("growth_commit").MustFloat64(0.2) | |||
RadarMap.GrowthComments = sec.Key("growth_comments").MustFloat64(0.2) | |||
} | |||
func loadInternalToken(sec *ini.Section) string { | |||
@@ -778,6 +778,53 @@ cloudbrain_operate=操作 | |||
cloudbrain_status_createtime=状态/创建时间 | |||
cloudbrain_jobname_err=只能以小写字母或数字开头且只包含小写字母、数字、_和-,不能以_结尾,最长36个字符。 | |||
modelarts.notebook=调试作业 | |||
modelarts.train_job=训练作业 | |||
modelarts.train_job.new=新建作业 | |||
modelarts.train_job.basic_info=基本信息 | |||
modelarts.train_job.job_status=作业状态 | |||
modelarts.train_job.job_name=作业名称 | |||
modelarts.train_job.version=作业版本 | |||
modelarts.train_job.start_time=开始时间 | |||
modelarts.train_job.dura_time=持续时间 | |||
modelarts.train_job.description=作业描述 | |||
modelarts.train_job.parameter_setting=参数设置 | |||
modelarts.train_job.parameter_setting_info=参数信息 | |||
modelarts.train_job.fast_parameter_setting=一键式参数配置 | |||
modelarts.train_job.fast_parameter_setting_config=如您已保存过参数配置,可单击 | |||
modelarts.train_job.fast_parameter_setting_config_link=这里 | |||
modelarts.train_job.frames=常用框架 | |||
modelarts.train_job.algorithm_origin=算法来源 | |||
modelarts.train_job.AI_driver=AI引擎 | |||
modelarts.train_job.start_file=启动文件 | |||
modelarts.train_job.boot_file_helper=启动文件是您程序执行的入口文件,必须是以.py结尾的文件。 | |||
modelarts.train_job.boot_file_place=填写启动文件路径,默认为train.py | |||
modelarts.train_job.dataset=数据集 | |||
modelarts.train_job.run_parameter=运行参数 | |||
modelarts.train_job.add_run_parameter=增加运行参数 | |||
modelarts.train_job.parameter_name=参数名 | |||
modelarts.train_job.parameter_value=参数值 | |||
modelarts.train_job.resource_setting=资源设置 | |||
modelarts.train_job.resource_setting_info=资源信息 | |||
modelarts.train_job.resource_pool=资源池 | |||
modelarts.train_job.resource_type=资源类型 | |||
modelarts.train_job.standard=规格 | |||
modelarts.train_job.NAS_address=NAS地址 | |||
modelarts.train_job.NAS_mount_path=NAS挂载路径 | |||
modelarts.train_job.query_whether_save_parameter=保存作业参数 | |||
modelarts.train_job.save_helper=保存当前作业的配置参数,后续您可以使用已保存的配置参数快速创建训练作业。 | |||
modelarts.train_job.common_frame=常用框架 | |||
modelarts.train_job.amount_of_compute_node=计算节点个数 | |||
modelarts.train_job.job_parameter_name=作业参数名称 | |||
modelarts.train_job.parameter_description=作业参数描述 | |||
modelarts.log=日志 | |||
modelarts.version_manage=版本管理 | |||
modelarts.back=返回 | |||
modelarts.train_job_para_admin=作业参数管理 | |||
modelarts.train_job_para.edit=编辑 | |||
modelarts.train_job_para.connfirm=确定 | |||
template.items=模板选项 | |||
template.git_content=Git数据(默认分支) | |||
template.git_hooks=Git 钩子 | |||
@@ -281,10 +281,10 @@ func ExploreDatasets(ctx *context.Context) { | |||
} | |||
pager := context.NewPagination(int(count), opts.PageSize, page, 5) | |||
ctx.Data["Keyword"] = opts.Keyword | |||
pager.SetDefaultParams(ctx) | |||
ctx.Data["Page"] = pager | |||
ctx.Data["Keyword"] = opts.Keyword | |||
ctx.Data["Datasets"] = datasets | |||
ctx.Data["Total"] = count | |||
ctx.Data["PageIsDatasets"] = true | |||
@@ -3,6 +3,8 @@ package repo | |||
import ( | |||
"time" | |||
"code.gitea.io/gitea/modules/normalization" | |||
"code.gitea.io/gitea/models" | |||
"code.gitea.io/gitea/modules/log" | |||
"code.gitea.io/gitea/modules/repository" | |||
@@ -17,6 +19,8 @@ func RepoStatisticAuto() { | |||
func RepoStatisticDaily(date string) { | |||
log.Info("%s", date) | |||
log.Info("begin Repo Statistic") | |||
t, _ := time.Parse("2006-01-02", "date") | |||
if err := models.DeleteRepoStatDaily(date); err != nil { | |||
log.Error("DeleteRepoStatDaily failed: %v", err.Error()) | |||
return | |||
@@ -28,13 +32,25 @@ func RepoStatisticDaily(date string) { | |||
return | |||
} | |||
for _, repo := range repos { | |||
var reposRadar = make([]*models.RepoStatistic, 0) | |||
var minRepoRadar models.RepoStatistic | |||
var maxRepoRadar models.RepoStatistic | |||
for i, repo := range repos { | |||
log.Info("start statistic: %s", repo.Name) | |||
var numDevMonths, numWikiViews, numContributor, numKeyContributor, numCommitsGrowth, numCommitLinesGrowth, numContributorsGrowth int64 | |||
repoGitStat, err := models.GetRepoKPIStats(repo) | |||
if err != nil { | |||
log.Error("GetRepoKPIStats failed: %s", repo.Name) | |||
log.Error("failed statistic: %s", repo.Name) | |||
continue | |||
} else { | |||
numDevMonths = repoGitStat.DevelopAge | |||
numKeyContributor = repoGitStat.KeyContributors | |||
numWikiViews = repoGitStat.WikiPages | |||
numContributor = repoGitStat.Contributors | |||
numCommitsGrowth = repoGitStat.CommitsAdded | |||
numCommitLinesGrowth = repoGitStat.CommitLinesModified | |||
numContributorsGrowth = repoGitStat.ContributorsAdded | |||
} | |||
var issueFixedRate float32 | |||
@@ -42,66 +58,178 @@ func RepoStatisticDaily(date string) { | |||
issueFixedRate = float32(repo.NumClosedIssues) / float32(repo.NumIssues) | |||
} | |||
numVersions, err := models.GetReleaseCountByRepoID(repo.ID, models.FindReleasesOptions{}) | |||
var numVersions int64 | |||
numVersions, err = models.GetReleaseCountByRepoID(repo.ID, models.FindReleasesOptions{}) | |||
if err != nil { | |||
log.Error("GetReleaseCountByRepoID failed: %s", repo.Name) | |||
log.Error("failed statistic: %s", repo.Name) | |||
continue | |||
log.Error("GetReleaseCountByRepoID failed(%s): %v", repo.Name, err) | |||
} | |||
datasetSize, err := getDatasetSize(repo) | |||
var datasetSize int64 | |||
datasetSize, err = getDatasetSize(repo) | |||
if err != nil { | |||
log.Error("getDatasetSize failed: %s", repo.Name) | |||
log.Error("failed statistic: %s", repo.Name) | |||
continue | |||
log.Error("getDatasetSize failed(%s): %v", repo.Name, err) | |||
} | |||
numComments, err := models.GetCommentCountByRepoID(repo.ID) | |||
var numComments int64 | |||
numComments, err = models.GetCommentCountByRepoID(repo.ID) | |||
if err != nil { | |||
log.Error("GetCommentCountByRepoID failed: %s", repo.Name) | |||
log.Error("failed statistic: %s", repo.Name) | |||
continue | |||
log.Error("GetCommentCountByRepoID failed(%s): %v", repo.Name, err) | |||
} | |||
beginTime, endTime := getStatTime(date) | |||
numVisits, err := repository.AppointProjectView(repo.OwnerName, repo.Name, beginTime, endTime) | |||
var numVisits int | |||
numVisits, err = repository.AppointProjectView(repo.OwnerName, repo.Name, beginTime, endTime) | |||
if err != nil { | |||
log.Error("Get numVisits failed", err) | |||
numVisits = 0 | |||
log.Error("AppointProjectView failed(%s): %v", repo.Name, err) | |||
} | |||
repoStat := models.RepoStatistic{ | |||
RepoID: repo.ID, | |||
Date: date, | |||
NumWatches: int64(repo.NumWatches), | |||
NumStars: int64(repo.NumStars), | |||
NumDownloads: repo.CloneCnt, | |||
NumComments: numComments, | |||
NumVisits: int64(numVisits), | |||
NumClosedIssues: int64(repo.NumClosedIssues), | |||
NumVersions: numVersions, | |||
NumDevMonths: repoGitStat.DevelopAge, | |||
RepoSize: repo.Size, | |||
DatasetSize: datasetSize, | |||
NumModels: 0, | |||
NumWikiViews: repoGitStat.WikiPages, | |||
NumCommits: repo.NumCommit, | |||
NumIssues: int64(repo.NumIssues), | |||
NumPulls: int64(repo.NumPulls), | |||
IssueFixedRate: issueFixedRate, | |||
NumContributor: repoGitStat.Contributors, | |||
NumKeyContributor: repoGitStat.KeyContributors, | |||
RepoID: repo.ID, | |||
Date: date, | |||
NumWatches: int64(repo.NumWatches), | |||
NumStars: int64(repo.NumStars), | |||
NumDownloads: repo.CloneCnt, | |||
NumComments: numComments, | |||
NumVisits: int64(numVisits), | |||
NumClosedIssues: int64(repo.NumClosedIssues), | |||
NumVersions: numVersions, | |||
NumDevMonths: numDevMonths, | |||
RepoSize: repo.Size, | |||
DatasetSize: datasetSize, | |||
NumModels: 0, | |||
NumWikiViews: numWikiViews, | |||
NumCommits: repo.NumCommit, | |||
NumIssues: int64(repo.NumIssues), | |||
NumPulls: int64(repo.NumPulls), | |||
IssueFixedRate: issueFixedRate, | |||
NumContributor: numContributor, | |||
NumKeyContributor: numKeyContributor, | |||
NumCommitsGrowth: numCommitsGrowth, | |||
NumCommitLinesGrowth: numCommitLinesGrowth, | |||
NumContributorsGrowth: numContributorsGrowth, | |||
} | |||
dayBeforeDate := t.AddDate(0, 0, -1).Format("2006-01-02") | |||
repoStatisticsBefore, err := models.GetRepoStatisticByDate(dayBeforeDate) | |||
if err != nil { | |||
log.Error("get data of day before the date failed ", err) | |||
} else { | |||
if len(repoStatisticsBefore) > 0 { | |||
repoStatisticBefore := repoStatisticsBefore[0] | |||
repoStat.NumWatchesAdded = repoStat.NumWatches - repoStatisticBefore.NumWatches | |||
repoStat.NumStarsAdded = repoStat.NumStars - repoStatisticBefore.NumStars | |||
repoStat.NumForksAdded = repoStat.NumForks - repoStatisticBefore.NumForks | |||
repoStat.NumDownloadsAdded = repoStat.NumDownloads - repoStatisticBefore.NumDownloads | |||
repoStat.NumCommentsAdded = repoStat.NumComments - repoStatisticBefore.NumComments | |||
repoStat.NumClosedIssuesAdded = repoStat.NumClosedIssues - repoStatisticBefore.NumClosedIssues | |||
repoStat.NumCommitsAdded = repoStat.NumCommits - repoStatisticBefore.NumCommits | |||
repoStat.NumIssuesAdded = repoStat.NumIssues - repoStatisticBefore.NumIssues | |||
repoStat.NumPullsAdded = repoStat.NumPulls - repoStatisticBefore.NumPulls | |||
repoStat.NumContributorAdded = repoStat.NumContributor - repoStatisticBefore.NumContributor | |||
} | |||
} | |||
day4MonthsAgo := t.AddDate(0, -4, 0) | |||
repoStatisticFourMonthsAgo, err := models.GetOneRepoStatisticBeforeTime(day4MonthsAgo) | |||
if err != nil { | |||
log.Error("Get data of 4 moth ago failed.", err) | |||
} else { | |||
repoStat.NumCommentsGrowth = repoStat.NumComments - repoStatisticFourMonthsAgo.NumComments | |||
repoStat.NumIssuesGrowth = repoStat.NumIssues - repoStatisticFourMonthsAgo.NumIssues | |||
} | |||
if _, err = models.InsertRepoStat(&repoStat); err != nil { | |||
log.Error("InsertRepoStat failed: %s", repo.Name) | |||
log.Error("InsertRepoStat failed(%s): %v", repo.Name, err) | |||
log.Error("failed statistic: %s", repo.Name) | |||
continue | |||
} | |||
tempRepoStat := models.RepoStatistic{ | |||
RepoID: repoStat.RepoID, | |||
Date: repoStat.Date, | |||
Impact: normalization.GetImpactInitValue(repoStat.NumWatches, repoStat.NumStars, repoStat.NumForks, repoStat.NumDownloads, repoStat.NumComments, repoStat.NumVisits), | |||
Completeness: normalization.GetCompleteInitValue(repoStat.NumClosedIssues, repoStat.NumVersions, repoStat.NumDevMonths, repoStat.DatasetSize, repoStat.NumModels, repoStat.NumWikiViews), | |||
Liveness: normalization.GetLivenessInitValue(repoStat.NumCommits, repoStat.NumIssues, repoStat.NumPulls, repoStat.NumVisits), | |||
ProjectHealth: normalization.GetProjectHealthInitValue(repoStat.IssueFixedRate), | |||
TeamHealth: normalization.GetTeamHealthInitValue(repoStat.NumContributor, repoStat.NumKeyContributor, repoStat.NumContributorsGrowth), | |||
Growth: normalization.GetRepoGrowthInitValue(repoStat.NumCommitLinesGrowth, repoStat.NumIssuesGrowth, repoStat.NumCommitsGrowth, repoStat.NumContributorsGrowth, repoStat.NumCommentsGrowth), | |||
} | |||
reposRadar = append(reposRadar, &tempRepoStat) | |||
if i == 0 { | |||
minRepoRadar = tempRepoStat | |||
maxRepoRadar = tempRepoStat | |||
} else { | |||
if tempRepoStat.Impact < minRepoRadar.Impact { | |||
minRepoRadar.Impact = tempRepoStat.Impact | |||
} | |||
if tempRepoStat.Impact > maxRepoRadar.Impact { | |||
maxRepoRadar.Impact = tempRepoStat.Impact | |||
} | |||
if tempRepoStat.Completeness < minRepoRadar.Completeness { | |||
minRepoRadar.Completeness = tempRepoStat.Completeness | |||
} | |||
if tempRepoStat.Completeness > maxRepoRadar.Completeness { | |||
maxRepoRadar.Completeness = tempRepoStat.Completeness | |||
} | |||
if tempRepoStat.Liveness < minRepoRadar.Completeness { | |||
minRepoRadar.Liveness = tempRepoStat.Liveness | |||
} | |||
if tempRepoStat.Liveness > maxRepoRadar.Liveness { | |||
maxRepoRadar.Liveness = tempRepoStat.Liveness | |||
} | |||
if tempRepoStat.ProjectHealth < minRepoRadar.ProjectHealth { | |||
minRepoRadar.ProjectHealth = tempRepoStat.ProjectHealth | |||
} | |||
if tempRepoStat.ProjectHealth > maxRepoRadar.ProjectHealth { | |||
maxRepoRadar.ProjectHealth = tempRepoStat.ProjectHealth | |||
} | |||
if tempRepoStat.TeamHealth < minRepoRadar.TeamHealth { | |||
minRepoRadar.TeamHealth = tempRepoStat.TeamHealth | |||
} | |||
if tempRepoStat.TeamHealth > maxRepoRadar.TeamHealth { | |||
maxRepoRadar.TeamHealth = tempRepoStat.TeamHealth | |||
} | |||
if tempRepoStat.Growth < minRepoRadar.Growth { | |||
minRepoRadar.Growth = tempRepoStat.Growth | |||
} | |||
if tempRepoStat.Growth > maxRepoRadar.Growth { | |||
maxRepoRadar.Growth = tempRepoStat.Growth | |||
} | |||
} | |||
log.Info("finish statistic: %s", repo.Name) | |||
} | |||
//radar map | |||
log.Info("begin statistic radar") | |||
for _, radarInit := range reposRadar { | |||
radarInit.Impact = normalization.Normalization(radarInit.Impact, minRepoRadar.Impact, maxRepoRadar.Impact) | |||
radarInit.Completeness = normalization.Normalization(radarInit.Completeness, minRepoRadar.Completeness, maxRepoRadar.Completeness) | |||
radarInit.Liveness = normalization.Normalization(radarInit.Liveness, minRepoRadar.Liveness, maxRepoRadar.Liveness) | |||
radarInit.ProjectHealth = normalization.Normalization(radarInit.ProjectHealth, minRepoRadar.ProjectHealth, maxRepoRadar.ProjectHealth) | |||
radarInit.TeamHealth = normalization.Normalization(radarInit.TeamHealth, minRepoRadar.TeamHealth, maxRepoRadar.TeamHealth) | |||
radarInit.Growth = normalization.Normalization(radarInit.Growth, minRepoRadar.Growth, maxRepoRadar.Growth) | |||
radarInit.RadarTotal = normalization.GetRadarValue(radarInit.Impact, radarInit.Completeness, radarInit.Liveness, radarInit.ProjectHealth, radarInit.TeamHealth, radarInit.Growth) | |||
models.UpdateRepoStat(radarInit) | |||
} | |||
log.Info("finish statistic: radar") | |||
} | |||
func getDatasetSize(repo *models.Repository) (int64, error) { | |||
@@ -114,14 +114,14 @@ func RouterHandler(level log.Level) func(ctx *macaron.Context) { | |||
} | |||
// SetLogMsgID set msgID in Context | |||
func SetLogMsgID() func(ctx *macaron.Context) { | |||
func SetLogMsgID() macaron.Handler { | |||
return func(ctx *macaron.Context) { | |||
start := time.Now() | |||
uuid := gouuid.NewV4().String() | |||
ctx.Data["MsgID"] = uuid | |||
log.Info("Started %s %s for %s", log.ColoredMethod(ctx.Req.Method), ctx.Req.URL.RequestURI(), ctx.RemoteAddr(), ctx.Data["MsgID"]) | |||
log.Info("%s Started %s %s for %s", ctx.Data["SignedUserName"], log.ColoredMethod(ctx.Req.Method), ctx.Req.URL.RequestURI(), ctx.RemoteAddr(), ctx.Data["MsgID"]) | |||
rw := ctx.Resp.(macaron.ResponseWriter) | |||
ctx.Next() | |||
@@ -149,7 +149,7 @@ func NewMacaron() *macaron.Macaron { | |||
m.Use(macaron.Logger()) | |||
} | |||
} | |||
m.Use(SetLogMsgID()) | |||
//m.Use(SetLogMsgID()) | |||
// Access Logger is similar to Router Log but more configurable and by default is more like the NCSA Common Log format | |||
if setting.EnableAccessLog { | |||
setupAccessLogger(m) | |||
@@ -257,6 +257,7 @@ func NewMacaron() *macaron.Macaron { | |||
DisableDebug: !setting.EnablePprof, | |||
})) | |||
m.Use(context.Contexter()) | |||
m.Use(SetLogMsgID()) | |||
// OK we are now set-up enough to allow us to create a nicer recovery than | |||
// the default macaron recovery | |||
m.Use(context.Recovery()) | |||
@@ -259,7 +259,7 @@ | |||
let value_task = $("input[name='job_name']").val() | |||
let value_image = $("input[name='image']").val() | |||
let value_data = $("input[name='attachment']").val() | |||
let re = /^[a-z0-9][a-z0-9-_]{1,35}[^_]$/ | |||
let re = /^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$/ | |||
let flag = re.test(value_task) | |||
if(!flag){ | |||
$('#messageInfo').css('display','block') | |||
@@ -17,7 +17,7 @@ | |||
<span class="ui basic basic button clipboard" data-clipboard-text="{{.DownloadURL}}" data-tooltip='{{$.i18n.Tr "dataset.copy_url"}}' data-clipboard-action="copy"{{if ne $.Type 0}} style="display:none;"{{end}}>{{svg "octicon-file" 16}}</span> | |||
<span class="ui basic basic button clipboard" data-clipboard-text="{{.FileChunk.Md5}}" data-tooltip='{{$.i18n.Tr "dataset.copy_md5"}}' data-clipboard-action="copy">{{svg "octicon-file-binary" 16}}</span> | |||
</div> | |||
{{if ne .DecompressState 0}} | |||
{{if eq .DecompressState 1}} | |||
<div class="ui left mini icon buttons"> | |||
<a class="ui basic blue button" href="datasets/dirs/{{.UUID}}?type={{$.Type}}" data-tooltip='{{$.i18n.Tr "dataset.directory"}}'>{{svg "octicon-file-directory" 16}}</a> | |||
{{if $.IsSigned}} | |||
@@ -164,7 +164,7 @@ export default { | |||
let findelement = this.array.some((item)=>{ | |||
return item.topic_name===this.input | |||
return item.topic_name===this.input.toLowerCase() | |||
}) | |||
this.showInputValue = !findelement | |||
@@ -250,7 +250,10 @@ export default { | |||
addPostTopic(){ | |||
if(this.showAddFlage){ | |||
this.arrayTopics.pop() | |||
// this.arrayTopics.pop() | |||
let cancleIndex = this.arrayTopics.indexOf(this.input) | |||
this.arrayTopics.splice(cancleIndex,1) | |||
let topics = this.arrayTopics | |||
let strTopics = topics.join(',') | |||
let data = this.qs.stringify({ | |||