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.

tool.go 2.2 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package private
  5. import (
  6. "net/http"
  7. "code.gitea.io/gitea/models"
  8. "code.gitea.io/gitea/modules/log"
  9. "code.gitea.io/gitea/routers/repo"
  10. "gitea.com/macaron/macaron"
  11. )
  12. func UpdateAllRepoCommitCnt(ctx *macaron.Context) {
  13. repos, err := models.GetAllRepositories()
  14. if err != nil {
  15. log.Error("GetAllRepositories failed:%v", err.Error(), ctx.Data["MsgID"])
  16. ctx.JSON(http.StatusInternalServerError, map[string]string{
  17. "error_msg": "GetAllRepositories failed",
  18. })
  19. return
  20. }
  21. for i, repo := range repos {
  22. log.Info("%d:begin updateRepoCommitCnt(id = %d, name = %s)", i, repo.ID, repo.Name)
  23. if err = updateRepoCommitCnt(ctx, repo); err != nil {
  24. log.Error("updateRepoCommitCnt(id = %d, name = %s) failed:%v", repo.ID, repo.Name, err.Error(), ctx.Data["MsgID"])
  25. continue
  26. }
  27. log.Info("%d:finish updateRepoCommitCnt(id = %d, name = %s)", i, repo.ID, repo.Name)
  28. }
  29. ctx.JSON(http.StatusOK, map[string]string{
  30. "error_msg": "",
  31. })
  32. }
  33. func RepoStatisticManually(ctx *macaron.Context) {
  34. date := ctx.Params("date")
  35. repo.RepoStatisticDaily(date)
  36. repo.SummaryStatisticDaily(date)
  37. repo.TimingCountDataByDate(date)
  38. }
  39. func OrgStatisticManually() {
  40. models.UpdateOrgStatistics()
  41. }
  42. func UpdateRepoVisit(ctx *macaron.Context) {
  43. date := ctx.Params("date")
  44. log.Info("date(%s)", date)
  45. repos, err := models.GetAllRepositories()
  46. if err != nil {
  47. log.Error("GetAllRepositories failed:%v", err.Error(), ctx.Data["MsgID"])
  48. ctx.JSON(http.StatusInternalServerError, map[string]string{
  49. "error_msg": "GetAllRepositories failed",
  50. })
  51. return
  52. }
  53. for i, repoStat := range repos {
  54. log.Info("%d:begin UpdateRepoVisits(id = %d, name = %s)", i, repoStat.ID, repoStat.Name)
  55. if err = repo.UpdateRepoVisits(ctx, repoStat, date); err != nil {
  56. log.Error("UpdateRepoVisits(id = %d, name = %s) failed:%v", repoStat.ID, repoStat.Name, err.Error())
  57. continue
  58. }
  59. log.Info("%d:finish UpdateRepoVisits(id = %d, name = %s)", i, repoStat.ID, repoStat.Name)
  60. }
  61. ctx.JSON(http.StatusOK, map[string]string{
  62. "error_msg": "",
  63. })
  64. }