update monthly aggregation and docs
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1319,6 +1319,10 @@ func formatHourIntervalLabel(start, end time.Time) string {
|
||||
return fmt.Sprintf("%s to %s", startLabel, end.Format("2006-01-02 15:04"))
|
||||
}
|
||||
|
||||
func formatDayIntervalLabel(start, end time.Time) string {
|
||||
return fmt.Sprintf("%s to %s", start.Format("2006-01-02"), end.Format("2006-01-02"))
|
||||
}
|
||||
|
||||
func buildDailyTotals(ctx context.Context, dbConn *sqlx.DB, records []SnapshotRecord, prorateByAvg bool) ([]totalsPoint, error) {
|
||||
points := make([]totalsPoint, 0, len(records))
|
||||
tinExpr := `COALESCE(SUM(CASE WHEN "Tin" IS NOT NULL THEN "Tin" ELSE 0 END) / 100.0, 0)`
|
||||
@@ -1374,8 +1378,11 @@ WHERE %s
|
||||
if err := dbConn.GetContext(ctx, &row, query); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dayTime := record.SnapshotTime.Local()
|
||||
dayStart := time.Date(dayTime.Year(), dayTime.Month(), dayTime.Day(), 0, 0, 0, 0, dayTime.Location())
|
||||
dayEnd := dayStart.AddDate(0, 0, 1)
|
||||
points = append(points, totalsPoint{
|
||||
Label: record.SnapshotTime.Local().Format("2006-01-02"),
|
||||
Label: formatDayIntervalLabel(dayStart, dayEnd),
|
||||
VmCount: float64(row.VmCount),
|
||||
VcpuTotal: row.VcpuTotal,
|
||||
RamTotal: row.RamTotal,
|
||||
|
||||
Reference in New Issue
Block a user