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.4 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.Query("date")
  35. repo.RepoStatisticDaily(date)
  36. repo.SummaryStatisticDaily(date)
  37. repo.TimingCountDataByDate(date)
  38. }
  39. /*
  40. func CreateModel(ctx *macaron.Context) {
  41. JobId := ctx.Query("JobId")
  42. VersionName := ctx.Query("VersionName")
  43. name := ctx.Query("Name")
  44. version := ctx.Query("Version")
  45. label := ctx.Query("Label")
  46. description := ctx.Query("Description")
  47. userId := ctx.QueryInt64("userId")
  48. repo.SaveModelByParameters(JobId, VersionName, name, version, label, description, userId)
  49. }
  50. func DeleteModel(ctx *macaron.Context) {
  51. id := ctx.Query("id")
  52. repo.DeleteModelByID(id)
  53. }
  54. func ShowModel(ctx *macaron.Context) {
  55. repoId := ctx.QueryInt64("repoId")
  56. page := ctx.QueryInt("page")
  57. modelResult, count, err := repo.QueryModelByParameters(repoId, page)
  58. if err == nil {
  59. log.Info("count=" + fmt.Sprint(count))
  60. //modelResultjson, _ := json.Marshal(modelResult)
  61. ctx.JSON(200, modelResult)
  62. } else {
  63. ctx.JSON(500, "query error.")
  64. }
  65. }
  66. func ModifyModel(ctx *macaron.Context) {
  67. id := ctx.Query("id")
  68. description := ctx.Query("Description")
  69. err := repo.ModifyModel(id, description)
  70. if err == nil {
  71. ctx.JSON(200, "Success.")
  72. } else {
  73. ctx.JSON(500, "Failed.")
  74. }
  75. }
  76. */