fix: gold kpi add granularity
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -47,17 +48,18 @@ type KpiReport struct {
|
||||
|
||||
type GoldKpi struct {
|
||||
// Id int `json:"-" xorm:"pk 'id' autoincr"`
|
||||
Date string `json:"date" xorm:"date"`
|
||||
Index int `json:"index"`
|
||||
StartTime string `json:"startTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
NEName string `json:"neName" xorm:"ne_name"`
|
||||
RmUid string `json:"rmUid" xorm:"rm_uid"`
|
||||
NEType string `json:"neType" xorm:"ne_type"`
|
||||
KpiId string `json:"kpiId" xorm:"kpi_id"`
|
||||
Value int `json:"value"`
|
||||
Error string `json:"error"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
Date string `json:"date" xorm:"date"`
|
||||
Index int `json:"index"`
|
||||
Granularity int8 `json:"granularity"`
|
||||
StartTime string `json:"startTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
NEName string `json:"neName" xorm:"ne_name"`
|
||||
RmUid string `json:"rmUid" xorm:"rm_uid"`
|
||||
NEType string `json:"neType" xorm:"ne_type"`
|
||||
KpiId string `json:"kpiId" xorm:"kpi_id"`
|
||||
Value int `json:"value"`
|
||||
Error string `json:"error"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -182,6 +184,12 @@ func PostKPIReportFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
goldKpi.Index, _ = strconv.Atoi(vars["index"])
|
||||
goldKpi.StartTime = global.GetFmtTimeString(layout, kpiReport.Task.Period.StartTime, time.DateTime)
|
||||
goldKpi.EndTime = global.GetFmtTimeString(layout, kpiReport.Task.Period.EndTime, time.DateTime)
|
||||
// get time granularity from startTime and endTime
|
||||
seconds, _ := global.GetSecondDuration(goldKpi.StartTime, goldKpi.EndTime)
|
||||
goldKpi.Granularity = 60
|
||||
if seconds != 0 && seconds <= math.MaxInt8 && seconds >= math.MinInt8 {
|
||||
goldKpi.Granularity = int8(seconds)
|
||||
}
|
||||
goldKpi.NEName = kpiReport.Task.NE.NEName
|
||||
goldKpi.RmUid = kpiReport.Task.NE.RmUID
|
||||
goldKpi.NEType = kpiReport.Task.NE.NeType
|
||||
|
||||
Reference in New Issue
Block a user