feat(dashboard): #162 include total sum of accounts compared to total savings
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 5m15s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 5m7s

This commit was merged in pull request #185.
This commit is contained in:
2025-06-16 23:00:38 +02:00
parent 596cc602d0
commit 06a8c80f1d
3 changed files with 38 additions and 11 deletions

View File

@@ -81,5 +81,31 @@ func (s Dashboard) Summary(ctx context.Context, user *types.User, month time.Tim
summary.Total = summary.Income + summary.Expenses
summary.Month = month
err = s.db.GetContext(ctx, &value, `
SELECT SUM(current_balance)
FROM treasure_chest
WHERE user_id = $1`,
user.Id)
err = db.TransformAndLogDbError("dashboard", nil, err)
if err != nil {
return nil, err
}
if value != nil {
summary.SumOfSavings = *value
}
err = s.db.GetContext(ctx, &value, `
SELECT SUM(current_balance)
FROM account
WHERE user_id = $1`,
user.Id)
err = db.TransformAndLogDbError("dashboard", nil, err)
if err != nil {
return nil, err
}
if value != nil {
summary.SumOfAccounts = *value
}
return &summary, nil
}