refactor code and improve daily cache handling of deleted VMs
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-01-20 16:46:07 +11:00
parent 0517ef88c3
commit 7ea02be91a
7 changed files with 131 additions and 122 deletions

View File

@@ -23,31 +23,6 @@ import (
"github.com/vmware/govmomi/vim25/types"
)
type InventorySnapshotRow struct {
InventoryId sql.NullInt64
Name string
Vcenter string
VmId sql.NullString
EventKey sql.NullString
CloudId sql.NullString
CreationTime sql.NullInt64
DeletionTime sql.NullInt64
ResourcePool sql.NullString
Datacenter sql.NullString
Cluster sql.NullString
Folder sql.NullString
ProvisionedDisk sql.NullFloat64
VcpuCount sql.NullInt64
RamGB sql.NullInt64
IsTemplate string
PoweredOn string
SrmPlaceholder string
VmUuid sql.NullString
SnapshotTime int64
}
type snapshotTotals = db.SnapshotTotals
// RunVcenterSnapshotHourly records hourly inventory snapshots into a daily table.
func (c *CronTask) RunVcenterSnapshotHourly(ctx context.Context, logger *slog.Logger) (err error) {
jobCtx := ctx
@@ -442,11 +417,6 @@ func filterRecordsInRange(records []report.SnapshotRecord, start, end time.Time)
return filtered
}
type columnDef struct {
Name string
Type string
}
var summaryUnionColumns = []string{
`"InventoryId"`, `"Name"`, `"Vcenter"`, `"VmId"`, `"EventKey"`, `"CloudId"`, `"CreationTime"`,
`"DeletionTime"`, `"ResourcePool"`, `"Datacenter"`, `"Cluster"`, `"Folder"`,