Capture running_balance from v2 API data.balance
This commit is contained in:
@@ -147,11 +147,14 @@ function processLogEntries($logEntries, $user, $insertStmt) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$runningBalance = isset($entry['data']['balance']) ? (int)$entry['data']['balance'] : null;
|
||||
|
||||
$insertStmt->bindValue(':id', $id);
|
||||
$insertStmt->bindValue(':user', $user);
|
||||
$insertStmt->bindValue(':timestamp', $timestamp);
|
||||
$insertStmt->bindValue(':description', $description);
|
||||
$insertStmt->bindValue(':amount', $amount);
|
||||
$insertStmt->bindValue(':running_balance', $runningBalance);
|
||||
$insertStmt->execute();
|
||||
}
|
||||
}
|
||||
@@ -250,8 +253,8 @@ function fetchAndStoreLogPage($pdo, $user, $url) {
|
||||
validateApiResponse($responseData);
|
||||
|
||||
$insertStmt = $pdo->prepare(
|
||||
'INSERT INTO vault (id, user, timestamp, description, amount) '
|
||||
. 'VALUES (:id, :user, :timestamp, :description, :amount) '
|
||||
'INSERT INTO vault (id, user, timestamp, description, amount, running_balance) '
|
||||
. 'VALUES (:id, :user, :timestamp, :description, :amount, :running_balance) '
|
||||
. 'ON CONFLICT(id) DO NOTHING'
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user