This commit is contained in:
@@ -586,8 +586,17 @@ func CreateTableReport(logger *slog.Logger, Database db.Database, ctx context.Co
|
|||||||
query = fmt.Sprintf(`%s WHERE %s`, query, templateExclusionFilter())
|
query = fmt.Sprintf(`%s WHERE %s`, query, templateExclusionFilter())
|
||||||
}
|
}
|
||||||
orderBy := snapshotOrderBy(columns)
|
orderBy := snapshotOrderBy(columns)
|
||||||
|
orderDir := "DESC"
|
||||||
|
isHourly := strings.HasPrefix(tableName, "inventory_hourly_")
|
||||||
|
isDailySummaryTable := strings.HasPrefix(tableName, "inventory_daily_summary_")
|
||||||
|
isMonthlySummaryTable := strings.HasPrefix(tableName, "inventory_monthly_summary_")
|
||||||
|
if hasColumn(columns, "CreationTime") && (isHourly || isDailySummaryTable || isMonthlySummaryTable) {
|
||||||
|
// Sort inventory rows by creation time ascending so newest VMs appear last.
|
||||||
|
orderBy = "CreationTime"
|
||||||
|
orderDir = "ASC"
|
||||||
|
}
|
||||||
if orderBy != "" {
|
if orderBy != "" {
|
||||||
query = fmt.Sprintf(`%s ORDER BY "%s" DESC`, query, orderBy)
|
query = fmt.Sprintf(`%s ORDER BY "%s" %s`, query, orderBy, orderDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := dbConn.QueryxContext(ctx, query)
|
rows, err := dbConn.QueryxContext(ctx, query)
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// UpdateCleanup removes orphaned update records.
|
// UpdateCleanup removes orphaned update records.
|
||||||
// @Summary Cleanup updates
|
// @Summary Cleanup updates (deprecated)
|
||||||
// @Description Removes update records that are no longer associated with a VM.
|
// @Description Deprecated: Removes update records that are no longer associated with a VM.
|
||||||
// @Tags maintenance
|
// @Tags maintenance
|
||||||
|
// @Deprecated
|
||||||
// @Produce text/plain
|
// @Produce text/plain
|
||||||
// @Success 200 {string} string "Cleanup completed"
|
// @Success 200 {string} string "Cleanup completed"
|
||||||
// @Failure 500 {string} string "Server error"
|
// @Failure 500 {string} string "Server error"
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// VcCleanup removes inventory entries for a vCenter instance.
|
// VcCleanup removes inventory entries for a vCenter instance.
|
||||||
// @Summary Cleanup vCenter inventory
|
// @Summary Cleanup vCenter inventory (deprecated)
|
||||||
// @Description Removes all inventory entries associated with a vCenter URL.
|
// @Description Deprecated: Removes all inventory entries associated with a vCenter URL.
|
||||||
// @Tags maintenance
|
// @Tags maintenance
|
||||||
|
// @Deprecated
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param vc_url query string true "vCenter URL"
|
// @Param vc_url query string true "vCenter URL"
|
||||||
// @Success 200 {object} map[string]string "Cleanup completed"
|
// @Success 200 {object} map[string]string "Cleanup completed"
|
||||||
|
|||||||
@@ -15,9 +15,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// VmCreateEvent records a VM creation CloudEvent.
|
// VmCreateEvent records a VM creation CloudEvent.
|
||||||
// @Summary Record VM create event
|
// @Summary Record VM create event (deprecated)
|
||||||
// @Description Parses a VM create CloudEvent and stores the event data.
|
// @Description Deprecated: Parses a VM create CloudEvent and stores the event data.
|
||||||
// @Tags events
|
// @Tags events
|
||||||
|
// @Deprecated
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce text/plain
|
// @Produce text/plain
|
||||||
// @Param event body models.CloudEventReceived true "CloudEvent payload"
|
// @Param event body models.CloudEventReceived true "CloudEvent payload"
|
||||||
|
|||||||
@@ -13,9 +13,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// VmDeleteEvent records a VM deletion CloudEvent in the inventory.
|
// VmDeleteEvent records a VM deletion CloudEvent in the inventory.
|
||||||
// @Summary Record VM delete event
|
// @Summary Record VM delete event (deprecated)
|
||||||
// @Description Parses a VM delete CloudEvent and marks the VM as deleted in inventory.
|
// @Description Deprecated: Parses a VM delete CloudEvent and marks the VM as deleted in inventory.
|
||||||
// @Tags events
|
// @Tags events
|
||||||
|
// @Deprecated
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce text/plain
|
// @Produce text/plain
|
||||||
// @Param event body models.CloudEventReceived true "CloudEvent payload"
|
// @Param event body models.CloudEventReceived true "CloudEvent payload"
|
||||||
|
|||||||
@@ -20,9 +20,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// VmModifyEvent records a VM modification CloudEvent.
|
// VmModifyEvent records a VM modification CloudEvent.
|
||||||
// @Summary Record VM modify event
|
// @Summary Record VM modify event (deprecated)
|
||||||
// @Description Parses a VM modify CloudEvent and creates an update record when relevant changes are detected.
|
// @Description Deprecated: Parses a VM modify CloudEvent and creates an update record when relevant changes are detected.
|
||||||
// @Tags events
|
// @Tags events
|
||||||
|
// @Deprecated
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param event body models.CloudEventReceived true "CloudEvent payload"
|
// @Param event body models.CloudEventReceived true "CloudEvent payload"
|
||||||
|
|||||||
@@ -15,9 +15,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// VmMoveEvent records a VM move CloudEvent as an update.
|
// VmMoveEvent records a VM move CloudEvent as an update.
|
||||||
// @Summary Record VM move event
|
// @Summary Record VM move event (deprecated)
|
||||||
// @Description Parses a VM move CloudEvent and creates an update record.
|
// @Description Deprecated: Parses a VM move CloudEvent and creates an update record.
|
||||||
// @Tags events
|
// @Tags events
|
||||||
|
// @Deprecated
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param event body models.CloudEventReceived true "CloudEvent payload"
|
// @Param event body models.CloudEventReceived true "CloudEvent payload"
|
||||||
|
|||||||
Reference in New Issue
Block a user