From 07838da0aded72259d1946db6448b85de246e942 Mon Sep 17 00:00:00 2001 From: pigwin Date: Tue, 7 Jan 2025 20:33:29 +0000 Subject: [PATCH] lolololololollollollol --- database/EstimatedCall.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/database/EstimatedCall.go b/database/EstimatedCall.go index 5d79520..f11dda1 100644 --- a/database/EstimatedCall.go +++ b/database/EstimatedCall.go @@ -42,9 +42,15 @@ func InsertOrUpdateEstimatedCall(ctx context.Context, db *sql.DB, values []inter } // Check if the retrieved value matches the original MD5 hash - if retrievedHash == hashString { - fmt.Println("Retrieved hash matches the original hash. No update needed.") - return 0, "no_update", nil + if retrievedHash != hashString { + return 0, "", fmt.Errorf("hash mismatch: original %s, retrieved %s", hashString, retrievedHash) + } + fmt.Println("Retrieved hash matches the original hash.") + + // Set the MD5 hash in Valkey + err = valki.SetValkeyValue(ctx, valkeyClient, key, hashString) + if err != nil { + return 0, "", fmt.Errorf("failed to set value in Valkey: %v", err) } query := ` @@ -78,14 +84,5 @@ func InsertOrUpdateEstimatedCall(ctx context.Context, db *sql.DB, values []inter if err != nil { return 0, "", fmt.Errorf("error executing statement: %v", err) } - - // If the record was inserted or updated, set the new hash in Valkey - if action == "insert" || action == "update" { - err = valki.SetValkeyValue(ctx, valkeyClient, key, hashString) - if err != nil { - return 0, "", fmt.Errorf("failed to set value in Valkey: %v", err) - } - } - return id, action, nil }