Browse Source

Merge remote-tracking branch 'origin/V20221130' into zouap

tags/v1.22.11.3^2
zouap 3 years ago
parent
commit
a91f5904b7
1 changed files with 5 additions and 7 deletions
  1. +5
    -7
      routers/repo/cloudbrain_statistic.go

+ 5
- 7
routers/repo/cloudbrain_statistic.go View File

@@ -16,19 +16,17 @@ import (
func CloudbrainDurationStatisticHour() { func CloudbrainDurationStatisticHour() {
var statisticTime time.Time var statisticTime time.Time
var count int64 var count int64
recordBeginTime, _ := time.ParseInLocation("2006-01-02 15:04:05", setting.Grampus.UsageRateBeginTime, time.Local)
recordDurationUpdateTime, err := models.GetDurationRecordUpdateTime() recordDurationUpdateTime, err := models.GetDurationRecordUpdateTime()
if err != nil { if err != nil {
log.Error("Can not get GetDurationRecordBeginTime", err) log.Error("Can not get GetDurationRecordBeginTime", err)
return
}
if recordDurationUpdateTime == nil {
statisticTime = recordBeginTime
} else {
statisticTime = time.Unix(int64(recordDurationUpdateTime[0].DateTime), 0)
} }
now := time.Now() now := time.Now()
currentTime := time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 0, 0, 0, now.Location()) currentTime := time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 0, 0, 0, now.Location())
if err == nil && len(recordDurationUpdateTime) > 0 {
statisticTime = time.Unix(int64(recordDurationUpdateTime[0].DateTime), 0)
} else {
statisticTime = currentTime.Add(-1 * time.Hour)
}


for statisticTime.Before(currentTime) || statisticTime.Equal(currentTime) { for statisticTime.Before(currentTime) || statisticTime.Equal(currentTime) {
countEach := summaryDurationStat(statisticTime) countEach := summaryDurationStat(statisticTime)


Loading…
Cancel
Save