cleanup updates with no vm reference
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-10-02 13:17:29 +10:00
parent f80dfe9027
commit 77c1928436
4 changed files with 34 additions and 17 deletions

View File

@@ -2,30 +2,31 @@ package handler
import (
"context"
"database/sql"
"fmt"
"net/http"
"time"
"vctp/db/queries"
)
// VmUpdate receives the CloudEvent for a VM modification or move
func (h *Handler) UpdateCleanup(w http.ResponseWriter, r *http.Request) {
// Get the current time
now := time.Now()
// Get the start of the current day (midnight today)
midnightToday := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
// Convert to Unix time
unixTime := midnightToday.Unix()
/*
// Get the current time
now := time.Now()
// Get the start of the current day (midnight today)
midnightToday := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
// Convert to Unix time
unixTime := midnightToday.Unix()
// create the database parameters
params := queries.CleanupUpdatesParams{
UpdateType: "diskchange",
UpdateTime: sql.NullInt64{Int64: unixTime, Valid: unixTime > 0},
}
// create the database parameters
params := queries.CleanupUpdatesParams{
UpdateType: "diskchange",
UpdateTime: sql.NullInt64{Int64: unixTime, Valid: unixTime > 0},
}
h.Logger.Debug("database params", "params", params)
err := h.Database.Queries().CleanupUpdates(context.Background(), params)
h.Logger.Debug("database params", "params", params)
err := h.Database.Queries().CleanupUpdates(context.Background(), params)
*/
err := h.Database.Queries().CleanupUpdatesNullVm(context.Background())
if err != nil {
h.Logger.Error("Error received cleaning updates table", "error", err)