@@ -11,8 +11,10 @@ import ( | |||||
type ContributorWithUserId struct { | type ContributorWithUserId struct { | ||||
git.Contributor | git.Contributor | ||||
UserId int64 | |||||
IsAdmin bool | |||||
UserId int64 | |||||
IsAdmin bool | |||||
RelAvatarLink string | |||||
Email string | |||||
} | } | ||||
func GetRepoKPIStats(repo *Repository) (*git.RepoKPIStats, error) { | func GetRepoKPIStats(repo *Repository) (*git.RepoKPIStats, error) { | ||||
@@ -146,6 +148,8 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { | |||||
contributor, | contributor, | ||||
user.ID, | user.ID, | ||||
user.IsAdmin, | user.IsAdmin, | ||||
user.RelAvatarLink(), | |||||
user.Email, | |||||
} | } | ||||
} else { | } else { | ||||
@@ -159,6 +163,8 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { | |||||
contributor, | contributor, | ||||
-1, | -1, | ||||
false, | false, | ||||
"", | |||||
contributor.Email, | |||||
} | } | ||||
} else { | } else { | ||||
value.CommitCnt += contributor.CommitCnt | value.CommitCnt += contributor.CommitCnt | ||||
@@ -164,13 +164,13 @@ func registerHandleBlockChainUnSuccessCommits() { | |||||
}) | }) | ||||
} | } | ||||
func registerHandleRepoStatistic() { | |||||
RegisterTaskFatal("handle_repo_statistic", &BaseConfig{ | |||||
func registerHandleRepoAndUserStatistic() { | |||||
RegisterTaskFatal("handle_repo_and_user_statistic", &BaseConfig{ | |||||
Enabled: true, | Enabled: true, | ||||
RunAtStart: false, | RunAtStart: false, | ||||
Schedule: "@daily", | Schedule: "@daily", | ||||
}, func(ctx context.Context, _ *models.User, _ Config) error { | }, func(ctx context.Context, _ *models.User, _ Config) error { | ||||
repo.RepoStatisticAuto() | |||||
repo.StatisticAuto() | |||||
return nil | return nil | ||||
}) | }) | ||||
} | } | ||||
@@ -185,16 +185,6 @@ func registerHandleSummaryStatistic() { | |||||
return nil | return nil | ||||
}) | }) | ||||
} | } | ||||
func registerHandleUserStatistic() { | |||||
RegisterTaskFatal("handle_user_statistic", &BaseConfig{ | |||||
Enabled: true, | |||||
RunAtStart: false, | |||||
Schedule: "@daily", | |||||
}, func(ctx context.Context, _ *models.User, _ Config) error { | |||||
repo.TimingCountData() | |||||
return nil | |||||
}) | |||||
} | |||||
func registerHandleClearRepoStatisticFile() { | func registerHandleClearRepoStatisticFile() { | ||||
RegisterTaskFatal("handle_repo_clear_statistic_file", &BaseConfig{ | RegisterTaskFatal("handle_repo_clear_statistic_file", &BaseConfig{ | ||||
@@ -222,7 +212,6 @@ func initBasicTasks() { | |||||
registerHandleBlockChainMergedPulls() | registerHandleBlockChainMergedPulls() | ||||
registerHandleBlockChainUnSuccessCommits() | registerHandleBlockChainUnSuccessCommits() | ||||
registerHandleRepoStatistic() | |||||
registerHandleUserStatistic() | |||||
registerHandleRepoAndUserStatistic() | |||||
registerHandleSummaryStatistic() | registerHandleSummaryStatistic() | ||||
} | } |
@@ -31,10 +31,12 @@ type ProjectsPeriodData struct { | |||||
} | } | ||||
type UserInfo struct { | type UserInfo struct { | ||||
User string `json:"user"` | |||||
Mode int `json:"mode"` | |||||
PR int64 `json:"pr"` | |||||
Commit int `json:"commit"` | |||||
User string `json:"user"` | |||||
Mode int `json:"mode"` | |||||
PR int64 `json:"pr"` | |||||
Commit int `json:"commit"` | |||||
RelAvatarLink string `json:"relAvatarLink"` | |||||
Email string `json:"email"` | |||||
} | } | ||||
type ProjectLatestData struct { | type ProjectLatestData struct { | ||||
@@ -316,10 +318,11 @@ func GetProjectLatestStatistics(ctx *context.Context) { | |||||
pr := models.GetPullCountByUserAndRepoId(repoIdInt, contributor.UserId) | pr := models.GetPullCountByUserAndRepoId(repoIdInt, contributor.UserId) | ||||
userInfo := UserInfo{ | userInfo := UserInfo{ | ||||
User: contributor.Committer, | |||||
Commit: contributor.CommitCnt, | |||||
Mode: mode, | |||||
PR: pr, | |||||
User: contributor.Committer, | |||||
Commit: contributor.CommitCnt, | |||||
Mode: mode, | |||||
PR: pr, | |||||
RelAvatarLink: contributor.RelAvatarLink, | |||||
} | } | ||||
users = append(users, userInfo) | users = append(users, userInfo) | ||||
@@ -3,18 +3,20 @@ 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/normalization" | |||||
"code.gitea.io/gitea/modules/repository" | "code.gitea.io/gitea/modules/repository" | ||||
"code.gitea.io/gitea/modules/setting" | |||||
) | ) | ||||
//auto daily or manually | |||||
func StatisticAuto() { | |||||
RepoStatisticAuto() | |||||
TimingCountData() | |||||
} | |||||
//auto daily | |||||
func RepoStatisticAuto() { | func RepoStatisticAuto() { | ||||
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() | setting.UpdateRadarMap() | ||||
RepoStatisticDaily(yesterday) | RepoStatisticDaily(yesterday) | ||||