|
|
@@ -49,9 +49,11 @@ func RepoStatisticDaily(date string) { |
|
|
|
var minRepoRadar models.RepoStatistic |
|
|
|
var maxRepoRadar models.RepoStatistic |
|
|
|
|
|
|
|
for i, repo := range repos { |
|
|
|
isInitMinMaxRadar := false |
|
|
|
|
|
|
|
for _, repo := range repos { |
|
|
|
log.Info("start statistic: %s", getDistinctProjectName(repo)) |
|
|
|
var numDevMonths, numWikiViews, numContributor, numKeyContributor, numCommitsGrowth, numCommitLinesGrowth, numContributorsGrowth int64 |
|
|
|
var numDevMonths, numWikiViews, numContributor, numKeyContributor, numCommitsGrowth, numCommitLinesGrowth, numContributorsGrowth, numCommits int64 |
|
|
|
repoGitStat, err := models.GetRepoKPIStats(repo) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetRepoKPIStats failed: %s", getDistinctProjectName(repo)) |
|
|
@@ -63,6 +65,8 @@ func RepoStatisticDaily(date string) { |
|
|
|
numCommitsGrowth = repoGitStat.CommitsAdded |
|
|
|
numCommitLinesGrowth = repoGitStat.CommitLinesModified |
|
|
|
numContributorsGrowth = repoGitStat.ContributorsAdded |
|
|
|
numCommits = repoGitStat.Commits |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var issueFixedRate float32 |
|
|
@@ -98,15 +102,15 @@ func RepoStatisticDaily(date string) { |
|
|
|
} |
|
|
|
|
|
|
|
repoStat := models.RepoStatistic{ |
|
|
|
RepoID: repo.ID, |
|
|
|
Date: date, |
|
|
|
Name: repo.Name, |
|
|
|
IsPrivate: repo.IsPrivate, |
|
|
|
OwnerName: repo.OwnerName, |
|
|
|
NumWatches: int64(repo.NumWatches), |
|
|
|
NumStars: int64(repo.NumStars), |
|
|
|
NumForks: int64(repo.NumForks), |
|
|
|
|
|
|
|
RepoID: repo.ID, |
|
|
|
Date: date, |
|
|
|
Name: repo.Name, |
|
|
|
IsPrivate: repo.IsPrivate, |
|
|
|
IsMirror: repo.IsMirror, |
|
|
|
OwnerName: repo.OwnerName, |
|
|
|
NumWatches: int64(repo.NumWatches), |
|
|
|
NumStars: int64(repo.NumStars), |
|
|
|
NumForks: int64(repo.NumForks), |
|
|
|
NumDownloads: repo.CloneCnt, |
|
|
|
NumComments: numComments, |
|
|
|
NumVisits: int64(numVisits), |
|
|
@@ -117,7 +121,7 @@ func RepoStatisticDaily(date string) { |
|
|
|
DatasetSize: datasetSize, |
|
|
|
NumModels: 0, |
|
|
|
NumWikiViews: numWikiViews, |
|
|
|
NumCommits: repo.NumCommit, |
|
|
|
NumCommits: numCommits, |
|
|
|
NumIssues: int64(repo.NumIssues), |
|
|
|
NumPulls: int64(repo.NumPulls), |
|
|
|
IssueFixedRate: issueFixedRate, |
|
|
@@ -167,6 +171,7 @@ func RepoStatisticDaily(date string) { |
|
|
|
tempRepoStat := models.RepoStatistic{ |
|
|
|
RepoID: repoStat.RepoID, |
|
|
|
Date: repoStat.Date, |
|
|
|
IsMirror: repoStat.IsMirror, |
|
|
|
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), |
|
|
@@ -177,57 +182,64 @@ func RepoStatisticDaily(date string) { |
|
|
|
|
|
|
|
reposRadar = append(reposRadar, &tempRepoStat) |
|
|
|
|
|
|
|
if i == 0 { |
|
|
|
minRepoRadar = tempRepoStat |
|
|
|
maxRepoRadar = tempRepoStat |
|
|
|
} else { |
|
|
|
if !isInitMinMaxRadar { |
|
|
|
|
|
|
|
if tempRepoStat.Impact < minRepoRadar.Impact { |
|
|
|
minRepoRadar.Impact = tempRepoStat.Impact |
|
|
|
if !setting.RadarMap.IgnoreMirrorRepo || (setting.RadarMap.IgnoreMirrorRepo && !tempRepoStat.IsMirror) { |
|
|
|
minRepoRadar = tempRepoStat |
|
|
|
maxRepoRadar = tempRepoStat |
|
|
|
isInitMinMaxRadar = true |
|
|
|
} |
|
|
|
|
|
|
|
if tempRepoStat.Impact > maxRepoRadar.Impact { |
|
|
|
maxRepoRadar.Impact = tempRepoStat.Impact |
|
|
|
} |
|
|
|
} else { |
|
|
|
if !setting.RadarMap.IgnoreMirrorRepo || (setting.RadarMap.IgnoreMirrorRepo && !tempRepoStat.IsMirror) { |
|
|
|
if tempRepoStat.Impact < minRepoRadar.Impact { |
|
|
|
minRepoRadar.Impact = tempRepoStat.Impact |
|
|
|
} |
|
|
|
|
|
|
|
if tempRepoStat.Completeness < minRepoRadar.Completeness { |
|
|
|
minRepoRadar.Completeness = tempRepoStat.Completeness |
|
|
|
} |
|
|
|
if tempRepoStat.Impact > maxRepoRadar.Impact { |
|
|
|
maxRepoRadar.Impact = tempRepoStat.Impact |
|
|
|
} |
|
|
|
|
|
|
|
if tempRepoStat.Completeness > maxRepoRadar.Completeness { |
|
|
|
maxRepoRadar.Completeness = tempRepoStat.Completeness |
|
|
|
} |
|
|
|
if tempRepoStat.Completeness < minRepoRadar.Completeness { |
|
|
|
minRepoRadar.Completeness = tempRepoStat.Completeness |
|
|
|
} |
|
|
|
|
|
|
|
if tempRepoStat.Liveness < minRepoRadar.Completeness { |
|
|
|
minRepoRadar.Liveness = tempRepoStat.Liveness |
|
|
|
} |
|
|
|
if tempRepoStat.Completeness > maxRepoRadar.Completeness { |
|
|
|
maxRepoRadar.Completeness = tempRepoStat.Completeness |
|
|
|
} |
|
|
|
|
|
|
|
if tempRepoStat.Liveness > maxRepoRadar.Liveness { |
|
|
|
maxRepoRadar.Liveness = tempRepoStat.Liveness |
|
|
|
} |
|
|
|
if tempRepoStat.Liveness < minRepoRadar.Completeness { |
|
|
|
minRepoRadar.Liveness = tempRepoStat.Liveness |
|
|
|
} |
|
|
|
|
|
|
|
if tempRepoStat.ProjectHealth < minRepoRadar.ProjectHealth { |
|
|
|
minRepoRadar.ProjectHealth = tempRepoStat.ProjectHealth |
|
|
|
} |
|
|
|
if tempRepoStat.Liveness > maxRepoRadar.Liveness { |
|
|
|
maxRepoRadar.Liveness = tempRepoStat.Liveness |
|
|
|
} |
|
|
|
|
|
|
|
if tempRepoStat.ProjectHealth > maxRepoRadar.ProjectHealth { |
|
|
|
maxRepoRadar.ProjectHealth = tempRepoStat.ProjectHealth |
|
|
|
} |
|
|
|
if tempRepoStat.ProjectHealth < minRepoRadar.ProjectHealth { |
|
|
|
minRepoRadar.ProjectHealth = tempRepoStat.ProjectHealth |
|
|
|
} |
|
|
|
|
|
|
|
if tempRepoStat.TeamHealth < minRepoRadar.TeamHealth { |
|
|
|
minRepoRadar.TeamHealth = tempRepoStat.TeamHealth |
|
|
|
} |
|
|
|
if tempRepoStat.ProjectHealth > maxRepoRadar.ProjectHealth { |
|
|
|
maxRepoRadar.ProjectHealth = tempRepoStat.ProjectHealth |
|
|
|
} |
|
|
|
|
|
|
|
if tempRepoStat.TeamHealth > maxRepoRadar.TeamHealth { |
|
|
|
maxRepoRadar.TeamHealth = tempRepoStat.TeamHealth |
|
|
|
} |
|
|
|
if tempRepoStat.TeamHealth < minRepoRadar.TeamHealth { |
|
|
|
minRepoRadar.TeamHealth = tempRepoStat.TeamHealth |
|
|
|
} |
|
|
|
|
|
|
|
if tempRepoStat.Growth < minRepoRadar.Growth { |
|
|
|
minRepoRadar.Growth = tempRepoStat.Growth |
|
|
|
} |
|
|
|
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 |
|
|
|
} |
|
|
|
|
|
|
|
if tempRepoStat.Growth > maxRepoRadar.Growth { |
|
|
|
maxRepoRadar.Growth = tempRepoStat.Growth |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@@ -238,13 +250,23 @@ func RepoStatisticDaily(date string) { |
|
|
|
//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) |
|
|
|
if radarInit.IsMirror && setting.RadarMap.IgnoreMirrorRepo { |
|
|
|
radarInit.Impact = 0 |
|
|
|
radarInit.Completeness = 0 |
|
|
|
radarInit.Liveness = 0 |
|
|
|
radarInit.ProjectHealth = 0 |
|
|
|
radarInit.TeamHealth = 0 |
|
|
|
radarInit.Growth = 0 |
|
|
|
radarInit.RadarTotal = 0 |
|
|
|
} else { |
|
|
|
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) |
|
|
|
} |
|
|
|
|
|
|
|