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_statistic.go 1.9 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package models
  2. import (
  3. "fmt"
  4. "time"
  5. "code.gitea.io/gitea/modules/timeutil"
  6. )
  7. // RepoStatistic statistic info of all repository
  8. type RepoStatistic struct {
  9. ID int64 `xorm:"pk autoincr"`
  10. RepoID int64 `xorm:"unique(s) NOT NULL"`
  11. Date time.Time `xorm:"unique(s) NOT NULL"`
  12. NumWatches int64 `xorm:"NOT NULL DEFAULT 0"`
  13. NumStars int64 `xorm:"NOT NULL DEFAULT 0"`
  14. NumForks int64 `xorm:"NOT NULL DEFAULT 0"`
  15. NumDownloads int64 `xorm:"NOT NULL DEFAULT 0"`
  16. NumComments int64 `xorm:"NOT NULL DEFAULT 0"`
  17. NumViews int64 `xorm:"NOT NULL DEFAULT 0"`
  18. NumClosedIssues int64 `xorm:"NOT NULL DEFAULT 0"`
  19. NumVersions int64 `xorm:"NOT NULL DEFAULT 0"`
  20. //develop months
  21. NumDevMonths int64 `xorm:"NOT NULL DEFAULT 0"`
  22. RepoSize int64 `xorm:"NOT NULL DEFAULT 0"`
  23. DatasetSize int64 `xorm:"NOT NULL DEFAULT 0"`
  24. NumModels int64 `xorm:"NOT NULL DEFAULT 0"`
  25. NumWikiViews int64 `xorm:"NOT NULL DEFAULT 0"`
  26. NumCommits int64 `xorm:"NOT NULL DEFAULT 0"`
  27. NumIssues int64 `xorm:"NOT NULL DEFAULT 0"`
  28. NumPulls int64 `xorm:"NOT NULL DEFAULT 0"`
  29. IssueFixedRate float32 `xorm:"NOT NULL"`
  30. NumContributor int64 `xorm:"NOT NULL DEFAULT 0"`
  31. NumKeyContributor int64 `xorm:"NOT NULL DEFAULT 0"`
  32. CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
  33. UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
  34. }
  35. func DeleteRepoStatDaily(date time.Time) error {
  36. sess := xStatistic.NewSession()
  37. defer sess.Close()
  38. if err := sess.Begin(); err != nil {
  39. return fmt.Errorf("Begin: %v", err)
  40. }
  41. if _, err := sess.Where("date = ?", date).Delete(&RepoStatistic{}); err != nil {
  42. return fmt.Errorf("Delete: %v", err)
  43. }
  44. if err := sess.Commit(); err != nil {
  45. sess.Close()
  46. return fmt.Errorf("Commit: %v", err)
  47. }
  48. sess.Close()
  49. return nil
  50. }