|
|
|
@@ -302,6 +302,7 @@ func GetAllCloudbrainsTrend(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { |
|
|
|
|
|
|
|
recordBeginTime, err := getBrainRecordBeginTime() |
|
|
|
if err != nil { |
|
|
|
log.Error("Can not get record begin time", err) |
|
|
|
@@ -489,6 +490,37 @@ func GetCloudbrainsDetailData(ctx *context.Context) { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func GetCloudbrainsHoursData(ctx *context.Context) { |
|
|
|
var debugOnePeriodCount int64 |
|
|
|
brainRecordBeginTime, err := getBrainRecordBeginTime() |
|
|
|
if err != nil { |
|
|
|
log.Error("Can not get brain record begin time", err) |
|
|
|
ctx.Error(http.StatusBadRequest, ctx.Tr("repo.brain_record_begintime_get_err")) |
|
|
|
return |
|
|
|
} |
|
|
|
queryType := ctx.QueryTrim("type") |
|
|
|
now := time.Now() |
|
|
|
if queryType != "" { |
|
|
|
if queryType == "all" { |
|
|
|
beginTime := brainRecordBeginTime |
|
|
|
endTime := now |
|
|
|
timeLayoutStr := "2006-01-02" |
|
|
|
dateBeginTime := beginTime.Format(timeLayoutStr) |
|
|
|
dateEndTime := endTime.Format(timeLayoutStr) |
|
|
|
debugOnePeriodCount, err := models.GetHourPeriodCount(dateBeginTime, dateEndTime) |
|
|
|
if err != nil { |
|
|
|
log.Error("Can not query debugOneCount.", err) |
|
|
|
ctx.Error(http.StatusBadRequest, ctx.Tr("debugOneCount_get_error")) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.JSON(http.StatusOK, map[string]interface{}{ |
|
|
|
"debugOnePeriodCount": debugOnePeriodCount, |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func getCloudbrainCount(beginTime time.Time, endTime time.Time) (int64, int64, int64, int64, int64, int64, int64, int64, int64, error) { |
|
|
|
debugOneCount, err := models.GetDebugOnePeriodCount(beginTime, endTime) |
|
|
|
if err != nil { |
|
|
|
|