Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.21.12.1^2
zouap 3 years ago
parent
commit
69858de7d0
7 changed files with 70 additions and 3 deletions
  1. +26
    -0
      models/ai_model_manage.go
  2. +1
    -0
      models/models.go
  3. +22
    -1
      models/repo.go
  4. +0
    -1
      routers/private/internal.go
  5. +6
    -0
      routers/repo/http.go
  6. +14
    -0
      routers/repo/user_data_analysis.go
  7. +1
    -1
      routers/routes/routes.go

+ 26
- 0
models/ai_model_manage.go View File

@@ -0,0 +1,26 @@
package models

import (
"code.gitea.io/gitea/modules/timeutil"
)

type AiModelManage struct {
ID int64 `xorm:"pk"`
Name string `xorm:"NOT NULL"`
Version string `xorm:"NOT NULL"`
Parent int64 `xorm:"NOT NULL"`
Type int `xorm:"NOT NULL"`
Size int64 `xorm:"NOT NULL"`
Description string `xorm:"varchar(2000)"`
Label string `xorm:"varchar(1000)"`
Path string `xorm:"varchar(400) NOT NULL"`
ConfigJson string `xorm:"text"`
DownloadCount int `xorm:"NOT NULL DEFAULT 0"`
Engine int `xorm:"NOT NULL DEFAULT 0"`
Status int `xorm:"NOT NULL DEFAULT 0"`
Accuracy string `xorm:"varchar(1000)"`
DatasetId int64 `xorm:"NULL"`
RepoId int64 `xorm:"NULL"`
CodePath string `xorm:"varchar(400) NULL"`
CreatedUnix timeutil.TimeStamp `xorm:"created"`
}

+ 1
- 0
models/models.go View File

@@ -133,6 +133,7 @@ func init() {
new(FileChunk),
new(BlockChain),
new(RecommendOrg),
new(AiModelManage),
)

tablesStatistic = append(tablesStatistic,


+ 22
- 1
models/repo.go View File

@@ -210,9 +210,12 @@ type Repository struct {
Balance string `xorm:"NOT NULL DEFAULT '0'"`
BlockChainStatus RepoBlockChainStatus `xorm:"NOT NULL DEFAULT 0"`

// git clone total count
// git clone and git pull total count
CloneCnt int64 `xorm:"NOT NULL DEFAULT 0"`

// only git clone total count
GitCloneCnt int64 `xorm:"NOT NULL DEFAULT 0"`

CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`

@@ -2473,6 +2476,24 @@ func (repo *Repository) IncreaseCloneCnt() {
return
}

func (repo *Repository) IncreaseGitCloneCnt() {
sess := x.NewSession()
defer sess.Close()

if err := sess.Begin(); err != nil {
return
}
if _, err := sess.Exec("UPDATE `repository` SET git_clone_cnt = git_clone_cnt + 1 WHERE id = ?", repo.ID); err != nil {
return
}

if err := sess.Commit(); err != nil {
return
}

return
}

func UpdateRepositoryCommitNum(repo *Repository) error {
if _, err := x.Exec("UPDATE `repository` SET num_commit = ? where id = ?", repo.NumCommit, repo.ID); err != nil {
return err


+ 0
- 1
routers/private/internal.go View File

@@ -44,6 +44,5 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/manager/flush-queues", bind(private.FlushOptions{}), FlushQueues)
m.Post("/tool/update_all_repo_commit_cnt", UpdateAllRepoCommitCnt)
m.Post("/tool/repo_stat", RepoStatisticManually)

}, CheckInternalToken)
}

+ 6
- 0
routers/repo/http.go View File

@@ -332,6 +332,12 @@ func HTTP(ctx *context.Context) {
go repo.IncreaseCloneCnt()
}

if ctx.Req.Method == "POST" {
if strings.HasSuffix(ctx.Req.URL.Path, "git-upload-pack") {
go repo.IncreaseGitCloneCnt()
}
}

w := ctx.Resp
r := ctx.Req.Request
cfg := &serviceConfig{


+ 14
- 0
routers/repo/user_data_analysis.go View File

@@ -1,13 +1,27 @@
package repo

import (
"fmt"
"net/http"
"time"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"gopkg.in/macaron.v1"
)

func QueryUserStaticData(ctx *macaron.Context) {
startDate := ctx.Query("startDate")
endDate := ctx.Query("endDate")
log.Info("startDate=" + startDate + " endDate=" + endDate)
startTime, _ := time.Parse("2006-01-02", startDate)
endTime, _ := time.Parse("2006-01-02", endDate)
log.Info("startTime=" + fmt.Sprint(startTime.Unix()) + " endDate=" + fmt.Sprint(endTime.Unix()))
ctx.JSON(http.StatusOK, models.QueryUserStaticData(startTime.Unix(), endTime.Unix()))

}

func TimingCountDataByDate(date string) {

t, _ := time.Parse("2006-01-02", date)


+ 1
- 1
routers/routes/routes.go View File

@@ -786,7 +786,7 @@ func RegisterRoutes(m *macaron.Macaron) {
}, reqSignIn, context.RepoAssignment(), context.UnitTypes(), reqRepoAdmin, context.RepoRef())

m.Post("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), context.UnitTypes(), repo.Action)
m.Get("/tool/query_user_static", repo.QueryUserStaticData)
// Grouping for those endpoints not requiring authentication
m.Group("/:username/:reponame", func() {
m.Group("/milestone", func() {


Loading…
Cancel
Save