add formatting to reports
Some checks are pending
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
CI / End-to-End (push) Waiting to run
CI / Publish Docker (push) Blocked by required conditions
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-27 11:41:09 +10:00
parent a18cca1f0e
commit 78e1da3149
5 changed files with 262 additions and 5 deletions

View File

@@ -44,6 +44,10 @@ INSERT INTO "Updates" (
)
RETURNING *;
-- name: GetReportUpdates :many
SELECT * FROM "Updates"
ORDER BY "UpdateTime";
-- name: CleanupUpdates :exec
DELETE FROM "Updates"
WHERE "UpdateType" = sqlc.arg('updateType') AND "UpdateTime" <= sqlc.arg('updateTime')

View File

@@ -379,6 +379,46 @@ func (q *Queries) GetReportInventory(ctx context.Context) ([]Inventory, error) {
return items, nil
}
const getReportUpdates = `-- name: GetReportUpdates :many
SELECT Uid, InventoryId, UpdateTime, UpdateType, NewVcpus, NewRam, NewResourcePool, EventKey, EventId, NewProvisionedDisk, UserName FROM "Updates"
ORDER BY "UpdateTime"
`
func (q *Queries) GetReportUpdates(ctx context.Context) ([]Updates, error) {
rows, err := q.db.QueryContext(ctx, getReportUpdates)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Updates
for rows.Next() {
var i Updates
if err := rows.Scan(
&i.Uid,
&i.InventoryId,
&i.UpdateTime,
&i.UpdateType,
&i.NewVcpus,
&i.NewRam,
&i.NewResourcePool,
&i.EventKey,
&i.EventId,
&i.NewProvisionedDisk,
&i.UserName,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const inventoryCleanup = `-- name: InventoryCleanup :exec
DELETE FROM "Inventory"
WHERE "VmId" = ?1 AND "Datacenter" = ?2