| @@ -221,6 +221,19 @@ func SaveModelToDb(model *AiModelManage) error { | |||||
| return nil | return nil | ||||
| } | } | ||||
| func QueryModelConvertByName(name string, repoId int64) ([]*AiModelConvert, error) { | |||||
| sess := x.NewSession() | |||||
| defer sess.Close() | |||||
| sess.Select("*").Table(new(AiModelConvert)). | |||||
| Where("name='" + name + "' and repo_id=" + fmt.Sprint(repoId)).OrderBy("created_unix desc") | |||||
| aiModelManageConvertList := make([]*AiModelConvert, 0) | |||||
| err := sess.Find(&aiModelManageConvertList) | |||||
| if err == nil { | |||||
| return aiModelManageConvertList, nil | |||||
| } | |||||
| return nil, err | |||||
| } | |||||
| func QueryModelConvertById(id string) (*AiModelConvert, error) { | func QueryModelConvertById(id string) (*AiModelConvert, error) { | ||||
| sess := x.NewSession() | sess := x.NewSession() | ||||
| defer sess.Close() | defer sess.Close() | ||||
| @@ -785,8 +785,9 @@ func isUserYearData(tableName string) bool { | |||||
| if currentTimeNow.Year() >= 2023 { | if currentTimeNow.Year() >= 2023 { | ||||
| return false | return false | ||||
| } | } | ||||
| return true | |||||
| } | } | ||||
| return true | |||||
| return false | |||||
| } | } | ||||
| func getBonusMap() map[string]map[string]int { | func getBonusMap() map[string]map[string]int { | ||||
| @@ -811,6 +812,7 @@ func getBonusMap() map[string]map[string]int { | |||||
| record, ok := bonusMap[userName] | record, ok := bonusMap[userName] | ||||
| if !ok { | if !ok { | ||||
| record = make(map[string]int) | record = make(map[string]int) | ||||
| bonusMap[userName] = record | |||||
| } | } | ||||
| record["times"] = getMapKeyStringValue("times", record) + getIntValue(aLine[3]) | record["times"] = getMapKeyStringValue("times", record) + getIntValue(aLine[3]) | ||||
| record["total_bonus"] = getMapKeyStringValue("total_bonus", record) + getIntValue(aLine[4]) | record["total_bonus"] = getMapKeyStringValue("total_bonus", record) + getIntValue(aLine[4]) | ||||
| @@ -763,6 +763,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| m.Group("/:username/:reponame", func() { | m.Group("/:username/:reponame", func() { | ||||
| m.Get("/right", reqToken(), repo.GetRight) | m.Get("/right", reqToken(), repo.GetRight) | ||||
| m.Get("/tagger", reqToken(), repo.ListTagger) | m.Get("/tagger", reqToken(), repo.ListTagger) | ||||
| m.Get("/cloudBrainJobId", repo.GetCloudBrainJobId) | |||||
| m.Combo("").Get(reqAnyRepoReader(), repo.Get). | m.Combo("").Get(reqAnyRepoReader(), repo.Get). | ||||
| Delete(reqToken(), reqOwner(), repo.Delete). | Delete(reqToken(), reqOwner(), repo.Delete). | ||||
| Patch(reqToken(), reqAdmin(), bind(api.EditRepoOption{}), context.RepoRef(), repo.Edit) | Patch(reqToken(), reqAdmin(), bind(api.EditRepoOption{}), context.RepoRef(), repo.Edit) | ||||
| @@ -1020,6 +1021,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| m.Delete("/delete_model", repo.DeleteModel) | m.Delete("/delete_model", repo.DeleteModel) | ||||
| m.Get("/downloadall", repo.DownloadModel) | m.Get("/downloadall", repo.DownloadModel) | ||||
| m.Get("/query_model_byId", repo.QueryModelById) | m.Get("/query_model_byId", repo.QueryModelById) | ||||
| m.Get("/query_model_byName", repo.QueryModelByName) | |||||
| m.Get("/query_model_for_predict", repo.QueryModelListForPredict) | m.Get("/query_model_for_predict", repo.QueryModelListForPredict) | ||||
| m.Get("/query_modelfile_for_predict", repo.QueryModelFileForPredict) | m.Get("/query_modelfile_for_predict", repo.QueryModelFileForPredict) | ||||
| m.Get("/query_train_model", repo.QueryTrainModelList) | m.Get("/query_train_model", repo.QueryTrainModelList) | ||||
| @@ -1027,6 +1029,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| m.Post("/convert_stop", repo.StopModelConvert) | m.Post("/convert_stop", repo.StopModelConvert) | ||||
| m.Get("/show_model_convert_page", repo.ShowModelConvertPage) | m.Get("/show_model_convert_page", repo.ShowModelConvertPage) | ||||
| m.Get("/query_model_convert_byId", repo.QueryModelConvertById) | m.Get("/query_model_convert_byId", repo.QueryModelConvertById) | ||||
| m.Get("/query_model_convert_byName", repo.QueryModelConvertByName) | |||||
| m.Get("/:id", repo.GetCloudbrainModelConvertTask) | m.Get("/:id", repo.GetCloudbrainModelConvertTask) | ||||
| m.Get("/:id/log", repo.CloudbrainForModelConvertGetLog) | m.Get("/:id/log", repo.CloudbrainForModelConvertGetLog) | ||||
| @@ -69,3 +69,17 @@ func GetRight(ctx *context.APIContext) { | |||||
| }) | }) | ||||
| } | } | ||||
| func GetCloudBrainJobId(ctx *context.APIContext) { | |||||
| cloudbrains, err := models.GetCloudbrainsByDisplayJobName(ctx.Repo.Repository.ID, ctx.Query("jobType"), ctx.Query("name")) | |||||
| if err != nil { | |||||
| log.Warn("get cloudbrain by display name failed", err) | |||||
| ctx.JSON(http.StatusOK, map[string]string{"jobId": ""}) | |||||
| return | |||||
| } | |||||
| if len(cloudbrains) > 0 { | |||||
| ctx.JSON(http.StatusOK, map[string]string{"jobId": cloudbrains[0].JobID}) | |||||
| return | |||||
| } | |||||
| ctx.JSON(http.StatusOK, map[string]string{"jobId": ""}) | |||||
| } | |||||
| @@ -43,6 +43,11 @@ func QueryModelById(ctx *context.APIContext) { | |||||
| routerRepo.QueryModelById(ctx.Context) | routerRepo.QueryModelById(ctx.Context) | ||||
| } | } | ||||
| func QueryModelByName(ctx *context.APIContext) { | |||||
| log.Info("QueryModelByName by api.") | |||||
| routerRepo.ShowSingleModel(ctx.Context) | |||||
| } | |||||
| func QueryModelListForPredict(ctx *context.APIContext) { | func QueryModelListForPredict(ctx *context.APIContext) { | ||||
| log.Info("QueryModelListForPredict by api.") | log.Info("QueryModelListForPredict by api.") | ||||
| ctx.Context.SetParams("isOnlyThisRepo", "true") | ctx.Context.SetParams("isOnlyThisRepo", "true") | ||||
| @@ -119,3 +124,12 @@ func QueryModelConvertById(ctx *context.APIContext) { | |||||
| ctx.JSON(http.StatusOK, nil) | ctx.JSON(http.StatusOK, nil) | ||||
| } | } | ||||
| } | } | ||||
| func QueryModelConvertByName(ctx *context.APIContext) { | |||||
| modelResult, err := routerRepo.GetModelConvertByName(ctx.Context) | |||||
| if err == nil { | |||||
| ctx.JSON(http.StatusOK, modelResult) | |||||
| } else { | |||||
| ctx.JSON(http.StatusOK, nil) | |||||
| } | |||||
| } | |||||
| @@ -758,6 +758,11 @@ func GetModelConvertById(ctx *context.Context) (*models.AiModelConvert, error) { | |||||
| return models.QueryModelConvertById(id) | return models.QueryModelConvertById(id) | ||||
| } | } | ||||
| func GetModelConvertByName(ctx *context.Context) ([]*models.AiModelConvert, error) { | |||||
| name := ctx.Query("name") | |||||
| return models.QueryModelConvertByName(name, ctx.Repo.Repository.ID) | |||||
| } | |||||
| func GetModelConvertPageData(ctx *context.Context) ([]*models.AiModelConvert, int64, error) { | func GetModelConvertPageData(ctx *context.Context) ([]*models.AiModelConvert, int64, error) { | ||||
| page := ctx.QueryInt("page") | page := ctx.QueryInt("page") | ||||
| if page <= 0 { | if page <= 0 { | ||||