You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

repo_activity_custom.go 986 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package models
  2. import "code.gitea.io/gitea/modules/git"
  3. func GetRepoKPIStats(repo *Repository) (*git.RepoKPIStats, error) {
  4. wikiPath := ""
  5. if repo.HasWiki() {
  6. wikiPath = repo.WikiPath()
  7. }
  8. return git.GetRepoKPIStats(repo.RepoPath(), wikiPath)
  9. }
  10. func GetAllUserKPIStats() (map[string]*git.UserKPIStats, error) {
  11. authors := make(map[string]*git.UserKPIStats)
  12. repositorys, err := GetAllRepositoriesByFilterCols("owner_name", "name")
  13. if err != nil {
  14. return nil, err
  15. }
  16. for _, repository := range repositorys {
  17. authorsOneRepo, err1 := git.GetUserKPIStats(repository.RepoPath())
  18. if err1 != nil {
  19. return nil, err
  20. }
  21. for key, value := range authorsOneRepo {
  22. if _, ok := authors[key]; !ok {
  23. authors[key] = &git.UserKPIStats{
  24. Name: value.Name,
  25. Email: value.Email,
  26. Commits: 0,
  27. CommitLines: 0,
  28. }
  29. }
  30. authors[key].Commits += value.Commits
  31. authors[key].CommitLines += value.CommitLines
  32. }
  33. }
  34. return authors, nil
  35. }