Add Getter for on/offbudget accounts and remove from backend

This commit is contained in:
2022-01-23 22:33:36 +00:00
parent 27298a9860
commit 0e3ece9830
3 changed files with 56 additions and 18 deletions

View File

@ -9,10 +9,8 @@ import (
)
type AlwaysNeededData struct {
Budget postgres.Budget
Accounts []postgres.GetAccountsWithBalanceRow
OnBudgetAccounts []postgres.GetAccountsWithBalanceRow
OffBudgetAccounts []postgres.GetAccountsWithBalanceRow
Budget postgres.Budget
Accounts []postgres.GetAccountsWithBalanceRow
}
func (h *Handler) getImportantData(c *gin.Context) {
@ -36,20 +34,9 @@ func (h *Handler) getImportantData(c *gin.Context) {
return
}
var onBudgetAccounts, offBudgetAccounts []postgres.GetAccountsWithBalanceRow
for _, account := range accounts {
if account.OnBudget {
onBudgetAccounts = append(onBudgetAccounts, account)
} else {
offBudgetAccounts = append(offBudgetAccounts, account)
}
}
base := AlwaysNeededData{
Accounts: accounts,
OnBudgetAccounts: onBudgetAccounts,
OffBudgetAccounts: offBudgetAccounts,
Budget: budget,
Accounts: accounts,
Budget: budget,
}
c.Set("data", base)