Browse Source

Merge pull request '项目每日增量指标,雷达图指标计算' (#610) from fix-473 into V20211101

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/610
Reviewed-by: lewis <747342561@qq.com>
pull/614/head
lewis 3 years ago
parent
commit
de25f24a89
5 changed files with 423 additions and 50 deletions
  1. +38
    -0
      custom/conf/app.ini.sample
  2. +80
    -27
      models/repo_statistic.go
  3. +83
    -0
      modules/normalization/normalization.go
  4. +72
    -0
      modules/setting/setting.go
  5. +150
    -23
      routers/repo/repo_statistic.go

+ 38
- 0
custom/conf/app.ini.sample View File

@@ -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

+ 80
- 27
models/repo_statistic.go View File

@@ -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
}

+ 83
- 0
modules/normalization/normalization.go View File

@@ -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)

}

+ 72
- 0
modules/setting/setting.go View File

@@ -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 {


+ 150
- 23
routers/repo/repo_statistic.go View File

@@ -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,9 +32,14 @@ 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 int64
var numDevMonths, numWikiViews, numContributor, numKeyContributor, numCommitsGrowth, numCommitLinesGrowth, numContributorsGrowth int64
repoGitStat, err := models.GetRepoKPIStats(repo)
if err != nil {
log.Error("GetRepoKPIStats failed: %s", repo.Name)
@@ -39,6 +48,9 @@ func RepoStatisticDaily(date string) {
numKeyContributor = repoGitStat.KeyContributors
numWikiViews = repoGitStat.WikiPages
numContributor = repoGitStat.Contributors
numCommitsGrowth = repoGitStat.CommitsAdded
numCommitLinesGrowth = repoGitStat.CommitLinesModified
numContributorsGrowth = repoGitStat.ContributorsAdded
}

var issueFixedRate float32
@@ -46,7 +58,7 @@ func RepoStatisticDaily(date string) {
issueFixedRate = float32(repo.NumClosedIssues) / float32(repo.NumIssues)
}

var numVersions int64
var numVersions int64
numVersions, err = models.GetReleaseCountByRepoID(repo.ID, models.FindReleasesOptions{})
if err != nil {
log.Error("GetReleaseCountByRepoID failed(%s): %v", repo.Name, err)
@@ -72,26 +84,58 @@ func RepoStatisticDaily(date string) {
}

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 {
@@ -100,9 +144,92 @@ func RepoStatisticDaily(date string) {
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) {


Loading…
Cancel
Save