From ee4e24aef0c3ede63ecc7f8bff36572924989476 Mon Sep 17 00:00:00 2001 From: Keith Solomon Date: Fri, 7 Aug 2026 18:41:15 -0500 Subject: [PATCH] vaultLoop: revert to SUM(amount) per user (v1 semantic) --- includes/utilities.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/includes/utilities.php b/includes/utilities.php index 760574b..78abca4 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -203,15 +203,12 @@ function vaultLoop ($name=null) { $pdo = getDatabaseConnection(); if ($name === null) { - $stmt = $pdo->query( - 'SELECT COALESCE(SUM(max_balance), 0) FROM ' - . '(SELECT MAX(running_balance) AS max_balance FROM vault GROUP BY user)' - ); + $stmt = $pdo->query('SELECT COALESCE(SUM(amount), 0) FROM vault'); return (int)$stmt->fetchColumn(); } - $stmt = $pdo->prepare('SELECT MAX(running_balance) FROM vault WHERE user = :user'); + $stmt = $pdo->prepare('SELECT COALESCE(SUM(amount), 0) FROM vault WHERE user = :user'); $stmt->bindValue(':user', $name); $stmt->execute();