Browse Source

fix 1233

tags/v1.22.1.1^2
lewis 3 years ago
parent
commit
94077bafec
3 changed files with 20 additions and 10 deletions
  1. +10
    -0
      modules/util/util.go
  2. +2
    -10
      routers/api/v1/repo/modelarts.go
  3. +8
    -0
      routers/repo/cloudbrain.go

+ 10
- 0
modules/util/util.go View File

@@ -6,6 +6,7 @@ package util

import (
"bytes"
"strconv"
"strings"
)

@@ -100,3 +101,12 @@ func NormalizeEOL(input []byte) []byte {
}
return tmp[:pos]
}

func AddZero(t int64) (m string) {
if t < 10 {
m = "0" + strconv.FormatInt(t, 10)
return m
} else {
return strconv.FormatInt(t, 10)
}
}

+ 2
- 10
routers/api/v1/repo/modelarts.go View File

@@ -6,6 +6,7 @@
package repo

import (
"code.gitea.io/gitea/modules/util"
"net/http"
"strconv"
"strings"
@@ -106,7 +107,7 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) {
job.TrainJobDuration = result.TrainJobDuration

if result.Duration != 0 {
job.TrainJobDuration = addZero(result.Duration/3600000) + ":" + addZero(result.Duration%3600000/60000) + ":" + addZero(result.Duration%60000/1000)
job.TrainJobDuration = util.AddZero(result.Duration/3600000) + ":" + util.AddZero(result.Duration%3600000/60000) + ":" + util.AddZero(result.Duration%60000/1000)

} else {
job.TrainJobDuration = "00:00:00"
@@ -125,15 +126,6 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) {

}

func addZero(t int64) (m string) {
if t < 10 {
m = "0" + strconv.FormatInt(t, 10)
return m
} else {
return strconv.FormatInt(t, 10)
}
}

func TrainJobGetLog(ctx *context.APIContext) {
var (
err error


+ 8
- 0
routers/repo/cloudbrain.go View File

@@ -2,6 +2,7 @@ package repo

import (
"bufio"
"code.gitea.io/gitea/modules/util"
"encoding/json"
"errors"
"fmt"
@@ -949,6 +950,13 @@ func SyncCloudbrainStatus() {
task.Duration = result.Duration
task.TrainJobDuration = result.TrainJobDuration

if result.Duration != 0 {
task.TrainJobDuration = util.AddZero(result.Duration/3600000) + ":" + util.AddZero(result.Duration%3600000/60000) + ":" + util.AddZero(result.Duration%60000/1000)

} else {
task.TrainJobDuration = "00:00:00"
}

err = models.UpdateJob(task)
if err != nil {
log.Error("UpdateJob(%s) failed:%v", task.JobName, err)


Loading…
Cancel
Save