web/multinode: fix used space graph showing 0
Resolves https://github.com/storj/storj/issues/5566 Change-Id: Ib9c81fa2c92ed71ccf07e7a0c9b6f61c46294f09
This commit is contained in:
parent
a229feac1e
commit
dab4288899
@ -85,6 +85,7 @@ func (service *Service) TotalUsage(ctx context.Context, from, to time.Time) (_ U
|
|||||||
}
|
}
|
||||||
|
|
||||||
var totalSummary float64
|
var totalSummary float64
|
||||||
|
var totalSummaryBytes float64
|
||||||
cache := make(UsageStampDailyCache)
|
cache := make(UsageStampDailyCache)
|
||||||
|
|
||||||
for _, node := range nodesList {
|
for _, node := range nodesList {
|
||||||
@ -98,14 +99,16 @@ func (service *Service) TotalUsage(ctx context.Context, from, to time.Time) (_ U
|
|||||||
}
|
}
|
||||||
|
|
||||||
totalSummary += usage.Summary
|
totalSummary += usage.Summary
|
||||||
|
totalSummaryBytes += usage.SummaryBytes
|
||||||
for _, stamp := range usage.Stamps {
|
for _, stamp := range usage.Stamps {
|
||||||
cache.Add(stamp)
|
cache.Add(stamp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Usage{
|
return Usage{
|
||||||
Stamps: cache.Sorted(),
|
Stamps: cache.Sorted(),
|
||||||
Summary: totalSummary,
|
Summary: totalSummary,
|
||||||
|
SummaryBytes: totalSummaryBytes,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +122,7 @@ func (service *Service) TotalUsageSatellite(ctx context.Context, satelliteID sto
|
|||||||
}
|
}
|
||||||
|
|
||||||
var totalSummary float64
|
var totalSummary float64
|
||||||
|
var totalSummaryBytes float64
|
||||||
cache := make(UsageStampDailyCache)
|
cache := make(UsageStampDailyCache)
|
||||||
|
|
||||||
for _, node := range nodesList {
|
for _, node := range nodesList {
|
||||||
@ -132,14 +136,16 @@ func (service *Service) TotalUsageSatellite(ctx context.Context, satelliteID sto
|
|||||||
}
|
}
|
||||||
|
|
||||||
totalSummary += usage.Summary
|
totalSummary += usage.Summary
|
||||||
|
totalSummaryBytes += usage.SummaryBytes
|
||||||
for _, stamp := range usage.Stamps {
|
for _, stamp := range usage.Stamps {
|
||||||
cache.Add(stamp)
|
cache.Add(stamp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Usage{
|
return Usage{
|
||||||
Stamps: cache.Sorted(),
|
Stamps: cache.Sorted(),
|
||||||
Summary: totalSummary,
|
Summary: totalSummary,
|
||||||
|
SummaryBytes: totalSummaryBytes,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,14 +252,16 @@ func (service *Service) dialUsage(ctx context.Context, node nodes.Node, from, to
|
|||||||
var stamps []UsageStamp
|
var stamps []UsageStamp
|
||||||
for _, usage := range resp.GetStorageUsage() {
|
for _, usage := range resp.GetStorageUsage() {
|
||||||
stamps = append(stamps, UsageStamp{
|
stamps = append(stamps, UsageStamp{
|
||||||
AtRestTotal: usage.GetAtRestTotal(),
|
AtRestTotal: usage.GetAtRestTotal(),
|
||||||
IntervalStart: usage.GetIntervalStart(),
|
AtRestTotalBytes: usage.GetAtRestTotalBytes(),
|
||||||
|
IntervalStart: usage.GetIntervalStart(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return Usage{
|
return Usage{
|
||||||
Stamps: stamps,
|
Stamps: stamps,
|
||||||
Summary: resp.GetSummary(),
|
Summary: resp.GetSummary(),
|
||||||
|
SummaryBytes: resp.GetAverageUsageBytes(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,13 +298,15 @@ func (service *Service) dialUsageSatellite(ctx context.Context, node nodes.Node,
|
|||||||
var stamps []UsageStamp
|
var stamps []UsageStamp
|
||||||
for _, usage := range resp.GetStorageUsage() {
|
for _, usage := range resp.GetStorageUsage() {
|
||||||
stamps = append(stamps, UsageStamp{
|
stamps = append(stamps, UsageStamp{
|
||||||
AtRestTotal: usage.GetAtRestTotal(),
|
AtRestTotal: usage.GetAtRestTotal(),
|
||||||
IntervalStart: usage.GetIntervalStart(),
|
AtRestTotalBytes: usage.GetAtRestTotalBytes(),
|
||||||
|
IntervalStart: usage.GetIntervalStart(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return Usage{
|
return Usage{
|
||||||
Stamps: stamps,
|
Stamps: stamps,
|
||||||
Summary: resp.GetSummary(),
|
Summary: resp.GetSummary(),
|
||||||
|
SummaryBytes: resp.GetAverageUsageBytes(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,16 @@ import (
|
|||||||
|
|
||||||
// Usage holds storage usage stamps and summary for a particular period.
|
// Usage holds storage usage stamps and summary for a particular period.
|
||||||
type Usage struct {
|
type Usage struct {
|
||||||
Stamps []UsageStamp `json:"stamps"`
|
Stamps []UsageStamp `json:"stamps"`
|
||||||
Summary float64 `json:"summary"`
|
Summary float64 `json:"summary"`
|
||||||
|
SummaryBytes float64 `json:"summaryBytes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UsageStamp holds data at rest total for an interval beginning at interval start.
|
// UsageStamp holds data at rest total for an interval beginning at interval start.
|
||||||
type UsageStamp struct {
|
type UsageStamp struct {
|
||||||
AtRestTotal float64 `json:"atRestTotal"`
|
AtRestTotal float64 `json:"atRestTotal"`
|
||||||
IntervalStart time.Time `json:"intervalStart"`
|
AtRestTotalBytes float64 `json:"atRestTotalBytes"`
|
||||||
|
IntervalStart time.Time `json:"intervalStart"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UsageStampDailyCache caches storage usage stamps by interval date.
|
// UsageStampDailyCache caches storage usage stamps by interval date.
|
||||||
@ -33,13 +35,15 @@ func (cache *UsageStampDailyCache) Add(stamp UsageStamp) {
|
|||||||
cacheStamp, ok := cached[intervalStart]
|
cacheStamp, ok := cached[intervalStart]
|
||||||
if ok {
|
if ok {
|
||||||
cached[intervalStart] = UsageStamp{
|
cached[intervalStart] = UsageStamp{
|
||||||
AtRestTotal: cacheStamp.AtRestTotal + stamp.AtRestTotal,
|
AtRestTotal: cacheStamp.AtRestTotal + stamp.AtRestTotal,
|
||||||
IntervalStart: intervalStart,
|
AtRestTotalBytes: cacheStamp.AtRestTotalBytes + stamp.AtRestTotalBytes,
|
||||||
|
IntervalStart: intervalStart,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cached[intervalStart] = UsageStamp{
|
cached[intervalStart] = UsageStamp{
|
||||||
AtRestTotal: stamp.AtRestTotal,
|
AtRestTotal: stamp.AtRestTotal,
|
||||||
IntervalStart: intervalStart,
|
AtRestTotalBytes: stamp.AtRestTotalBytes,
|
||||||
|
IntervalStart: intervalStart,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user