improve lifecycle data
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-01-28 08:49:04 +11:00
parent 93b5769145
commit ee01d8deac
6 changed files with 304 additions and 197 deletions

View File

@@ -1199,7 +1199,7 @@ agg_presence AS (
agg."VcpuCount",
agg."RamGB",
agg.pool,
COALESCE(agg.creation_time, lifecycle.first_seen) AS creation_time,
agg.creation_time AS creation_time,
COALESCE(lifecycle.deleted_at, agg.deletion_time) AS deletion_time,
%s AS presence
FROM agg

View File

@@ -155,11 +155,6 @@ func (c *CronTask) aggregateDailySummary(ctx context.Context, targetTime time.Ti
} else {
c.Logger.Info("Daily aggregation deletion times", "source_lifecycle_cache", applied)
}
if applied, err := db.ApplyLifecycleCreationToSummary(ctx, dbConn, summaryTable); err != nil {
c.Logger.Warn("failed to apply lifecycle creations to daily summary", "error", err, "table", summaryTable)
} else if applied > 0 {
c.Logger.Info("Daily aggregation creation times", "source_lifecycle_cache", applied)
}
if err := db.RefineCreationDeletionFromUnion(ctx, dbConn, summaryTable, unionQuery); err != nil {
c.Logger.Warn("failed to refine creation/deletion times", "error", err, "table", summaryTable)
}
@@ -411,11 +406,6 @@ LIMIT 1
} else {
c.Logger.Debug("refined creation/deletion times", "table", summaryTable)
}
if applied, err := db.ApplyLifecycleCreationToSummary(ctx, dbConn, summaryTable); err != nil {
c.Logger.Warn("failed to apply lifecycle creations to daily summary (Go path)", "error", err, "table", summaryTable)
} else if applied > 0 {
c.Logger.Info("Daily aggregation creation times (Go path)", "source_lifecycle_cache", applied)
}
if err := db.UpdateSummaryPresenceByWindow(ctx, dbConn, summaryTable, dayStart.Unix(), dayEnd.Unix()); err != nil {
c.Logger.Warn("failed to update daily AvgIsPresent from lifecycle window (Go path)", "error", err, "table", summaryTable)
}

View File

@@ -171,11 +171,6 @@ func (c *CronTask) aggregateMonthlySummary(ctx context.Context, targetMonth time
} else {
c.Logger.Info("Monthly aggregation deletion times", "source_lifecycle_cache", applied)
}
if applied, err := db.ApplyLifecycleCreationToSummary(ctx, dbConn, monthlyTable); err != nil {
c.Logger.Warn("failed to apply lifecycle creations to monthly summary", "error", err, "table", monthlyTable)
} else if applied > 0 {
c.Logger.Info("Monthly aggregation creation times", "source_lifecycle_cache", applied)
}
if err := db.UpdateSummaryPresenceByWindow(ctx, dbConn, monthlyTable, monthStart.Unix(), monthEnd.Unix()); err != nil {
c.Logger.Warn("failed to update monthly AvgIsPresent from lifecycle window", "error", err, "table", monthlyTable)
}
@@ -298,11 +293,6 @@ func (c *CronTask) aggregateMonthlySummaryGoHourly(ctx context.Context, monthSta
if err := c.insertDailyAggregates(ctx, summaryTable, aggMap, totalSamples, totalSamplesByVcenter); err != nil {
return err
}
if applied, err := db.ApplyLifecycleCreationToSummary(ctx, dbConn, summaryTable); err != nil {
c.Logger.Warn("failed to apply lifecycle creations to monthly summary (Go hourly)", "error", err, "table", summaryTable)
} else if applied > 0 {
c.Logger.Info("Monthly aggregation creation times (Go hourly)", "source_lifecycle_cache", applied)
}
if err := db.UpdateSummaryPresenceByWindow(ctx, dbConn, summaryTable, monthStart.Unix(), monthEnd.Unix()); err != nil {
c.Logger.Warn("failed to update monthly AvgIsPresent from lifecycle window (Go hourly)", "error", err, "table", summaryTable)
}
@@ -375,11 +365,6 @@ func (c *CronTask) aggregateMonthlySummaryGo(ctx context.Context, monthStart, mo
} else {
c.Logger.Info("Monthly aggregation deletion times", "source_lifecycle_cache", applied)
}
if applied, err := db.ApplyLifecycleCreationToSummary(ctx, dbConn, summaryTable); err != nil {
c.Logger.Warn("failed to apply lifecycle creations to monthly summary (Go)", "error", err, "table", summaryTable)
} else if applied > 0 {
c.Logger.Info("Monthly aggregation creation times (Go)", "source_lifecycle_cache", applied)
}
if err := db.RefineCreationDeletionFromUnion(ctx, dbConn, summaryTable, unionQuery); err != nil {
c.Logger.Warn("failed to refine creation/deletion times (monthly Go)", "error", err, "table", summaryTable)