Skip to content

Commit

Permalink
debug task db query
Browse files Browse the repository at this point in the history
  • Loading branch information
isaaguilar committed May 2, 2024
1 parent 295d08e commit 133457f
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions pkg/api/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ func (h APIHandler) AddTaskPod(c *gin.Context) {
TaskName string `json:"task_name"`
UUID string `json:"uuid"`
InClusterGeneration string `json:"generation"`

Content string `json:"content"`
Content string `json:"content"`
}{}
err = c.BindJSON(&jsonData)
if err != nil {
Expand All @@ -45,7 +44,7 @@ func (h APIHandler) AddTaskPod(c *gin.Context) {

rerunID, err := strconv.Atoi(jsonData.RerunID)
if err != nil {
c.JSON(http.StatusUnprocessableEntity, response(http.StatusUnprocessableEntity, fmt.Sprintf("rerun is must be an int, got %s", jsonData.RerunID), nil))
c.JSON(http.StatusUnprocessableEntity, response(http.StatusUnprocessableEntity, fmt.Sprintf("rerun_id must be numeric, got %s", jsonData.RerunID), nil))
return
}

Expand Down Expand Up @@ -87,10 +86,6 @@ func (h APIHandler) AddTaskPod(c *gin.Context) {
func saveTaskLog(db *gorm.DB, taskUUID, content string) error {
now := time.Now().UTC()
taskLog := models.TFOTaskLog{
Model: gorm.Model{
CreatedAt: now,
UpdatedAt: now,
},
TaskPodUUID: taskUUID,
Message: content,
Size: uint64(len([]byte(content))),
Expand All @@ -109,7 +104,7 @@ func saveTaskLog(db *gorm.DB, taskUUID, content string) error {
taskLog.UpdatedAt = now
taskLog.Message += string([]byte(content)[taskLog.Size:])
taskLog.Size = uint64(len([]byte(taskLog.Message)))
if result := db.Save(&taskLog); result.Error != nil {
if result := db.Debug().Save(&taskLog); result.Error != nil {
return result.Error
}
}
Expand Down

0 comments on commit 133457f

Please sign in to comment.