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())
|
||||
}
|
||||
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 != "" {
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user