Browse Source

1

tags/v1.21.12.1
lewis 3 years ago
parent
commit
c6bedceb50
2 changed files with 37 additions and 2 deletions
  1. +4
    -0
      models/repo_statistic.go
  2. +33
    -2
      routers/repo/repo_statistic.go

+ 4
- 0
models/repo_statistic.go View File

@@ -57,3 +57,7 @@ func DeleteRepoStatDaily(date time.Time) error {
sess.Close()
return nil
}

func InsertRepoStat(repoStat *RepoStatistic) (int64, error) {
return xStatistic.Insert(repoStat)
}

+ 33
- 2
routers/repo/repo_statistic.go View File

@@ -26,13 +26,44 @@ func RepoStatisticDaily() {

for _, repo := range repos {
log.Info("start statistic: %s", repo.Name)
repoStat, err := models.GetRepoKPIStats(repo)
repoGitStat, err := models.GetRepoKPIStats(repo)
if err != nil {
log.Error("GetRepoKPIStats failed: %s", repo.Name)
log.Error("failed statistic: %s", repo.Name)
continue
}
log.Info("", repoStat.DevelopAge)
log.Info("", repoGitStat.DevelopAge)

repoStat := models.RepoStatistic{
RepoID: repo.ID,
Date:yesterday,
NumWatches:int64(repo.NumWatches),
NumStars:int64(repo.NumStars),
NumDownloads:repo.CloneCnt,
NumComments:0,
NumViews:0,
NumClosedIssues:0,
NumVersions:0,
NumDevMonths:repoGitStat.DevelopAge,
RepoSize:0,
DatasetSize:0,
NumModels:0,
NumWikiViews:0,
NumCommits:0,
NumIssues:0,
NumPulls:0,
IssueFixedRate:0,
NumContributor:repoGitStat.Contributors,
NumKeyContributor:repoGitStat.KeyContributors,

}

if _, err = models.InsertRepoStat(&repoStat); err != nil {
log.Error("InsertRepoStat failed: %s", repo.Name)
log.Error("failed statistic: %s", repo.Name)
continue
}

log.Info("finish statistic: %s", repo.Name)
}



Loading…
Cancel
Save