Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.21.12.1^2
zouap 4 years ago
parent
commit
3b2c6c6316
3 changed files with 71 additions and 3 deletions
  1. +16
    -1
      models/ai_model_manage.go
  2. +53
    -0
      routers/repo/ai_model_manage.go
  3. +2
    -2
      routers/repo/user_data_analysis.go

+ 16
- 1
models/ai_model_manage.go View File

@@ -1,11 +1,14 @@
package models

import (
"fmt"

"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/timeutil"
)

type AiModelManage struct {
ID int64 `xorm:"pk"`
ID string `xorm:"pk"`
Name string `xorm:"NOT NULL"`
Version string `xorm:"NOT NULL"`
Parent int64 `xorm:"NOT NULL"`
@@ -24,3 +27,15 @@ type AiModelManage struct {
CodePath string `xorm:"varchar(400) NULL"`
CreatedUnix timeutil.TimeStamp `xorm:"created"`
}

func SaveModelToDb(model *AiModelManage) error {
sess := x.NewSession()
defer sess.Close()

re, err := sess.Insert(model)
if err != nil {
return err
}
log.Info("success to save db.re=" + fmt.Sprint((re)))
return nil
}

+ 53
- 0
routers/repo/ai_model_manage.go View File

@@ -0,0 +1,53 @@
package repo

import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/log"
uuid "github.com/satori/go.uuid"
)

func SaveModel(ctx *context.Context) {
log.Info("save model start.")
jobId := ctx.QueryInt64("JobId")
name := ctx.Query("Name")

aiTasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{
JobID: jobId,
})
if err != nil {
log.Info("query task error.")
return
}
if count > 0 {
for _, task := range aiTasks {
log.Info("find task name:" + task.JobName)

}
}

id := uuid.NewV4()

model := &models.AiModelManage{
ID: id.String(),
Name: name,
}

models.SaveModelToDb(model)

log.Info("save model end.")
}

func DeleteModel(ctx *context.Context) {
log.Info("delete model start.")
}

func DownloadModel(ctx *context.Context) {
log.Info("download model start.")

}

func ShowModelInfo(ctx *context.Context) {
log.Info("ShowModelInfo.")

}

+ 2
- 2
routers/repo/user_data_analysis.go View File

@@ -6,12 +6,12 @@ import (
"time"

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

func QueryUserStaticData(ctx *macaron.Context) {
func QueryUserStaticData(ctx *context.Context) {
startDate := ctx.Query("startDate")
endDate := ctx.Query("endDate")
log.Info("startDate=" + startDate + " endDate=" + endDate)


Loading…
Cancel
Save