diff --git a/models/repo_statistic.go b/models/repo_statistic.go index 5fddb769e..afe32bcb9 100755 --- a/models/repo_statistic.go +++ b/models/repo_statistic.go @@ -57,3 +57,7 @@ func DeleteRepoStatDaily(date time.Time) error { sess.Close() return nil } + +func InsertRepoStat(repoStat *RepoStatistic) (int64, error) { + return xStatistic.Insert(repoStat) +} diff --git a/routers/repo/repo_statistic.go b/routers/repo/repo_statistic.go index 85184db21..ceb206218 100755 --- a/routers/repo/repo_statistic.go +++ b/routers/repo/repo_statistic.go @@ -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) }