@@ -1102,3 +1102,41 @@ PROJECT_NAME = cn-south-222_test | |||||
USERNAME = test1 | USERNAME = test1 | ||||
PASSWORD = Qizhi@test. | PASSWORD = Qizhi@test. | ||||
DOMAIN = cn-south-222 | 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 | package models | ||||
import ( | import ( | ||||
"code.gitea.io/gitea/modules/timeutil" | |||||
"fmt" | "fmt" | ||||
"time" | |||||
"code.gitea.io/gitea/modules/timeutil" | |||||
) | ) | ||||
// RepoStatistic statistic info of all repository | // RepoStatistic statistic info of all repository | ||||
type RepoStatistic struct { | 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 { | func DeleteRepoStatDaily(date string) error { | ||||
@@ -55,6 +79,35 @@ func DeleteRepoStatDaily(date string) error { | |||||
return nil | 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) { | func InsertRepoStat(repoStat *RepoStatistic) (int64, error) { | ||||
return xStatistic.Insert(repoStat) | 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 | |||||
} |
@@ -28,7 +28,7 @@ var ( | |||||
ResourceSpecs *models.ResourceSpecs | ResourceSpecs *models.ResourceSpecs | ||||
) | ) | ||||
func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType, gpuQueue string, resourceSpecId int) error { | |||||
func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, brainScorePath, jobType, gpuQueue string, resourceSpecId int) error { | |||||
dataActualPath := setting.Attachment.Minio.RealPath + | dataActualPath := setting.Attachment.Minio.RealPath + | ||||
setting.Attachment.Minio.Bucket + "/" + | setting.Attachment.Minio.Bucket + "/" + | ||||
setting.Attachment.Minio.BasePath + | setting.Attachment.Minio.BasePath + | ||||
@@ -104,6 +104,13 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, | |||||
ReadOnly: true, | ReadOnly: true, | ||||
}, | }, | ||||
}, | }, | ||||
{ | |||||
HostPath: models.StHostPath{ | |||||
Path: brainScorePath, | |||||
MountPath: BrainScoreMountPath, | |||||
ReadOnly: true, | |||||
}, | |||||
}, | |||||
}, | }, | ||||
}) | }) | ||||
if err != nil { | if err != nil { | ||||
@@ -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) | |||||
} |
@@ -0,0 +1,7 @@ | |||||
package setting | |||||
func UpdateRadarMap() { | |||||
Cfg.DeleteSection("radar_map") | |||||
Cfg.Reload() | |||||
SetRadarMapConfig() | |||||
} |
@@ -498,6 +498,44 @@ var ( | |||||
//nginx proxy | //nginx proxy | ||||
PROXYURL string | 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. | // DateLang transforms standard language locale name to corresponding value in datetime plugin. | ||||
@@ -1232,6 +1270,44 @@ func NewContext() { | |||||
TimeField = sec.Key("TIMEFIELD").MustString(" @timestamptest") | TimeField = sec.Key("TIMEFIELD").MustString(" @timestamptest") | ||||
ElkTimeFormat = sec.Key("ELKTIMEFORMAT").MustString("date_time") | ElkTimeFormat = sec.Key("ELKTIMEFORMAT").MustString("date_time") | ||||
SetRadarMapConfig() | |||||
} | |||||
func SetRadarMapConfig() { | |||||
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 { | func loadInternalToken(sec *ini.Section) string { | ||||
@@ -262,7 +262,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { | |||||
downloadRateCode(repo, jobName, setting.BrainScoreCode, brainScorePath, "", "") | downloadRateCode(repo, jobName, setting.BrainScoreCode, brainScorePath, "", "") | ||||
} | } | ||||
err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType, gpuQueue, resourceSpecId) | |||||
err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, brainScorePath, jobType, gpuQueue, resourceSpecId) | |||||
if err != nil { | if err != nil { | ||||
cloudBrainNewDataPrepare(ctx) | cloudBrainNewDataPrepare(ctx) | ||||
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) | ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) | ||||
@@ -3,6 +3,10 @@ package repo | |||||
import ( | import ( | ||||
"time" | "time" | ||||
"code.gitea.io/gitea/modules/setting" | |||||
"code.gitea.io/gitea/modules/normalization" | |||||
"code.gitea.io/gitea/models" | "code.gitea.io/gitea/models" | ||||
"code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
"code.gitea.io/gitea/modules/repository" | "code.gitea.io/gitea/modules/repository" | ||||
@@ -12,11 +16,14 @@ import ( | |||||
func RepoStatisticAuto() { | func RepoStatisticAuto() { | ||||
log.Info("", time.Now()) | log.Info("", time.Now()) | ||||
yesterday := time.Now().AddDate(0, 0, -1).Format("2006-01-02") | yesterday := time.Now().AddDate(0, 0, -1).Format("2006-01-02") | ||||
setting.UpdateRadarMap() | |||||
RepoStatisticDaily(yesterday) | RepoStatisticDaily(yesterday) | ||||
} | } | ||||
func RepoStatisticDaily(date string) { | func RepoStatisticDaily(date string) { | ||||
log.Info("%s", date) | log.Info("%s", date) | ||||
log.Info("begin Repo Statistic") | |||||
t, _ := time.Parse("2006-01-02", "date") | |||||
if err := models.DeleteRepoStatDaily(date); err != nil { | if err := models.DeleteRepoStatDaily(date); err != nil { | ||||
log.Error("DeleteRepoStatDaily failed: %v", err.Error()) | log.Error("DeleteRepoStatDaily failed: %v", err.Error()) | ||||
return | return | ||||
@@ -28,9 +35,14 @@ func RepoStatisticDaily(date string) { | |||||
return | 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) | log.Info("start statistic: %s", repo.Name) | ||||
var numDevMonths,numWikiViews,numContributor,numKeyContributor int64 | |||||
var numDevMonths, numWikiViews, numContributor, numKeyContributor, numCommitsGrowth, numCommitLinesGrowth, numContributorsGrowth int64 | |||||
repoGitStat, err := models.GetRepoKPIStats(repo) | repoGitStat, err := models.GetRepoKPIStats(repo) | ||||
if err != nil { | if err != nil { | ||||
log.Error("GetRepoKPIStats failed: %s", repo.Name) | log.Error("GetRepoKPIStats failed: %s", repo.Name) | ||||
@@ -39,6 +51,9 @@ func RepoStatisticDaily(date string) { | |||||
numKeyContributor = repoGitStat.KeyContributors | numKeyContributor = repoGitStat.KeyContributors | ||||
numWikiViews = repoGitStat.WikiPages | numWikiViews = repoGitStat.WikiPages | ||||
numContributor = repoGitStat.Contributors | numContributor = repoGitStat.Contributors | ||||
numCommitsGrowth = repoGitStat.CommitsAdded | |||||
numCommitLinesGrowth = repoGitStat.CommitLinesModified | |||||
numContributorsGrowth = repoGitStat.ContributorsAdded | |||||
} | } | ||||
var issueFixedRate float32 | var issueFixedRate float32 | ||||
@@ -46,7 +61,7 @@ func RepoStatisticDaily(date string) { | |||||
issueFixedRate = float32(repo.NumClosedIssues) / float32(repo.NumIssues) | issueFixedRate = float32(repo.NumClosedIssues) / float32(repo.NumIssues) | ||||
} | } | ||||
var numVersions int64 | |||||
var numVersions int64 | |||||
numVersions, err = models.GetReleaseCountByRepoID(repo.ID, models.FindReleasesOptions{}) | numVersions, err = models.GetReleaseCountByRepoID(repo.ID, models.FindReleasesOptions{}) | ||||
if err != nil { | if err != nil { | ||||
log.Error("GetReleaseCountByRepoID failed(%s): %v", repo.Name, err) | log.Error("GetReleaseCountByRepoID failed(%s): %v", repo.Name, err) | ||||
@@ -72,26 +87,58 @@ func RepoStatisticDaily(date string) { | |||||
} | } | ||||
repoStat := models.RepoStatistic{ | 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: 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, | |||||
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 { | if _, err = models.InsertRepoStat(&repoStat); err != nil { | ||||
@@ -100,9 +147,92 @@ func RepoStatisticDaily(date string) { | |||||
continue | 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) | 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) { | func getDatasetSize(repo *models.Repository) (int64, error) { | ||||
@@ -138,9 +138,15 @@ | |||||
<label>任务类型</label> | <label>任务类型</label> | ||||
<select id="cloudbrain_job_type" class="ui search dropdown" placeholder="选择任务类型" style='width:385px' name="job_type"> | <select id="cloudbrain_job_type" class="ui search dropdown" placeholder="选择任务类型" style='width:385px' name="job_type"> | ||||
<option name="job_type" value="DEBUG">DEBUG</option> | <option name="job_type" value="DEBUG">DEBUG</option> | ||||
<option name="job_type" value="BENCHMARK">BENCHMARK</option> | |||||
<option name="job_type" value="SNN4IMAGENET">SNN4IMAGENET</option> | |||||
<option name="job_type" value="BRAINSCORE">BRAINSCORE</option> | |||||
{{if .is_benchmark_enabled}} | |||||
<option name="job_type" value="BENCHMARK">BENCHMARK</option> | |||||
{{end}} | |||||
{{if .is_snn4imagenet_enabled}} | |||||
<option name="job_type" value="SNN4IMAGENET">SNN4IMAGENET</option> | |||||
{{end}} | |||||
{{if .is_brainscore_enabled}} | |||||
<option name="job_type" value="BRAINSCORE">BRAINSCORE</option> | |||||
{{end}} | |||||
</select> | </select> | ||||
</div> | </div> | ||||
@@ -214,15 +220,15 @@ | |||||
</div> | </div> | ||||
<div class="inline required field cloudbrain_benchmark"> | <div class="inline required field cloudbrain_benchmark"> | ||||
<label>benchmark脚本存放路径</label> | <label>benchmark脚本存放路径</label> | ||||
<input name="benchmark_path" id="cloudbrain_benchmark_path" value="{{.benchmark_path}}" tabindex="3" autofocus required maxlength="255" readonly="readonly"> | |||||
<input name="benchmark_path" id="cloudbrain_benchmark_path" value="{{.benchmark_path}}" tabindex="3" disabled autofocus required maxlength="255" readonly="readonly"> | |||||
</div> | </div> | ||||
<div class="inline required field cloudbrain_snn4imagenet"> | <div class="inline required field cloudbrain_snn4imagenet"> | ||||
<label>snn4imagenet脚本存放路径</label> | <label>snn4imagenet脚本存放路径</label> | ||||
<input name="snn4imagenet_path" id="cloudbrain_snn4imagenet_path" value="{{.snn4imagenet_path}}" tabindex="3" autofocus required maxlength="255" readonly="readonly"> | |||||
<input name="snn4imagenet_path" id="cloudbrain_snn4imagenet_path" value="{{.snn4imagenet_path}}" tabindex="3" disabled autofocus required maxlength="255" readonly="readonly"> | |||||
</div> | </div> | ||||
<div class="inline required field cloudbrain_brainscore"> | <div class="inline required field cloudbrain_brainscore"> | ||||
<label>brainscore脚本存放路径</label> | <label>brainscore脚本存放路径</label> | ||||
<input name="brainscore_path" id="cloudbrain_brainscore_path" value="{{.brainscore_path}}" tabindex="3" autofocus required maxlength="255" readonly="readonly"> | |||||
<input name="brainscore_path" id="cloudbrain_brainscore_path" value="{{.brainscore_path}}" tabindex="3" disabled autofocus required maxlength="255" readonly="readonly"> | |||||
</div> | </div> | ||||
<div class="inline required field" hidden> | <div class="inline required field" hidden> | ||||
<label>启动命令</label> | <label>启动命令</label> | ||||