// Copyright 2020 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package private import ( "fmt" "net/http" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/routers/repo" "gitea.com/macaron/macaron" ) func UpdateAllRepoCommitCnt(ctx *macaron.Context) { repos, err := models.GetAllRepositories() if err != nil { log.Error("GetAllRepositories failed:%v", err.Error(), ctx.Data["MsgID"]) ctx.JSON(http.StatusInternalServerError, map[string]string{ "error_msg": "GetAllRepositories failed", }) return } for i, repo := range repos { log.Info("%d:begin updateRepoCommitCnt(id = %d, name = %s)", i, repo.ID, repo.Name) if err = updateRepoCommitCnt(ctx, repo); err != nil { log.Error("updateRepoCommitCnt(id = %d, name = %s) failed:%v", repo.ID, repo.Name, err.Error(), ctx.Data["MsgID"]) continue } log.Info("%d:finish updateRepoCommitCnt(id = %d, name = %s)", i, repo.ID, repo.Name) } ctx.JSON(http.StatusOK, map[string]string{ "error_msg": "", }) } func RepoStatisticManually(ctx *macaron.Context) { date := ctx.Query("date") repo.RepoStatisticDaily(date) repo.SummaryStatisticDaily(date) repo.TimingCountDataByDate(date) } func CreateModel(ctx *macaron.Context) { trainTaskId := ctx.Query("TrainTask") name := ctx.Query("Name") version := ctx.Query("Version") label := ctx.Query("Label") description := ctx.Query("Description") userId := ctx.QueryInt64("userId") repo.SaveModelByParameters(trainTaskId, name, version, label, description, userId) } func DeleteModel(ctx *macaron.Context) { id := ctx.Query("id") repo.DeleteModelByID(id) } func ShowModel(ctx *macaron.Context) { repoId := ctx.QueryInt64("repoId") page := ctx.QueryInt("page") modelResult, count, err := repo.QueryModelByParameters(repoId, page) if err == nil { log.Info("count=" + fmt.Sprint(count)) //modelResultjson, _ := json.Marshal(modelResult) ctx.JSON(200, modelResult) } else { ctx.JSON(500, "query error.") } } func ModifyModel(ctx *macaron.Context) { id := ctx.Query("id") description := ctx.Query("Description") err := repo.ModifyModel(id, description) if err == nil { ctx.JSON(200, "Success.") } else { ctx.JSON(500, "Failed.") } }