|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package models
-
- import (
- "code.gitea.io/gitea/modules/timeutil"
- "fmt"
- )
-
- // RepoStatistic statistic info of all repository
- type RepoStatistic struct {
- ID int64 `xorm:"pk autoincr"`
- RepoID int64 `xorm:"unique(s) NOT NULL"`
- Date string `xorm:"unique(s) NOT NULL"`
- NumWatches int64 `xorm:"NOT NULL DEFAULT 0"`
- NumStars int64 `xorm:"NOT NULL DEFAULT 0"`
- NumForks int64 `xorm:"NOT NULL DEFAULT 0"`
- NumDownloads int64 `xorm:"NOT NULL DEFAULT 0"`
- NumComments int64 `xorm:"NOT NULL DEFAULT 0"`
- NumVisits int64 `xorm:"NOT NULL DEFAULT 0"`
- NumClosedIssues int64 `xorm:"NOT NULL DEFAULT 0"`
- NumVersions int64 `xorm:"NOT NULL DEFAULT 0"`
- //develop months
- NumDevMonths int64 `xorm:"NOT NULL DEFAULT 0"`
- RepoSize int64 `xorm:"NOT NULL DEFAULT 0"`
- DatasetSize int64 `xorm:"NOT NULL DEFAULT 0"`
- NumModels int64 `xorm:"NOT NULL DEFAULT 0"`
- NumWikiViews int64 `xorm:"NOT NULL DEFAULT 0"`
- NumCommits int64 `xorm:"NOT NULL DEFAULT 0"`
- NumIssues int64 `xorm:"NOT NULL DEFAULT 0"`
- NumPulls int64 `xorm:"NOT NULL DEFAULT 0"`
- IssueFixedRate float32 `xorm:"NOT NULL"`
- NumContributor int64 `xorm:"NOT NULL DEFAULT 0"`
- NumKeyContributor int64 `xorm:"NOT NULL DEFAULT 0"`
-
- CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
- UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
- }
-
- func DeleteRepoStatDaily(date string) error {
- sess := xStatistic.NewSession()
- defer sess.Close()
- if err := sess.Begin(); err != nil {
- return fmt.Errorf("Begin: %v", err)
- }
-
- if _, err := sess.Where("date = ?", date).Delete(&RepoStatistic{}); err != nil {
- return fmt.Errorf("Delete: %v", err)
- }
-
- if err := sess.Commit(); err != nil {
- sess.Close()
- return fmt.Errorf("Commit: %v", err)
- }
-
- sess.Close()
- return nil
- }
-
- func InsertRepoStat(repoStat *RepoStatistic) (int64, error) {
- return xStatistic.Insert(repoStat)
- }
|