feat: extract into remaining packages
All checks were successful
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 1m19s

There has been a cyclic dependency.
transaction
	-> treasure_chest
	-> transaction_recurring
	-> transaction

This has been temporarily solved by moving the GenerateTransactions
function into the transaction package. In the future, this function has
to be rewritten to use a proper Service insteas of direct DB access or
replaced with a different system entirely.
This commit is contained in:
2025-12-31 22:24:21 +01:00
parent 6de8d8fb10
commit 1be46780bb
29 changed files with 230 additions and 251 deletions

View File

@@ -5,9 +5,7 @@ import (
"log/slog"
"net/http"
"spend-sparrow/internal/core"
"spend-sparrow/internal/dashboard/template"
"spend-sparrow/internal/treasure_chest"
"spend-sparrow/internal/utils"
"strings"
"time"
@@ -45,7 +43,7 @@ func (handler HandlerImpl) handleDashboard() http.HandlerFunc {
user := core.GetUser(r)
if user == nil {
utils.DoRedirect(w, r, "/auth/signin")
core.DoRedirect(w, r, "/auth/signin")
return
}
@@ -55,7 +53,7 @@ func (handler HandlerImpl) handleDashboard() http.HandlerFunc {
return
}
comp := template.Dashboard(treasureChests)
comp := DashboardComp(treasureChests)
handler.r.RenderLayoutWithStatus(r, w, comp, user, http.StatusOK)
}
}

View File

@@ -4,9 +4,9 @@ import (
"context"
"spend-sparrow/internal/auth_types"
"spend-sparrow/internal/core"
"spend-sparrow/internal/transaction"
"spend-sparrow/internal/treasure_chest"
"spend-sparrow/internal/treasure_chest_types"
"spend-sparrow/internal/types"
"time"
"github.com/google/uuid"
@@ -31,7 +31,7 @@ func (s Service) MainChart(
return nil, core.ErrUnauthorized
}
transactions := make([]types.Transaction, 0)
transactions := make([]transaction.Transaction, 0)
err := s.db.SelectContext(ctx, &transactions, `
SELECT *
FROM "transaction"
@@ -130,7 +130,7 @@ func (s Service) TreasureChest(
return nil, core.ErrUnauthorized
}
transactions := make([]types.Transaction, 0)
transactions := make([]transaction.Transaction, 0)
err := s.db.SelectContext(ctx, &transactions, `
SELECT *
FROM "transaction"

View File

@@ -1,8 +1,8 @@
package template
package dashboard
import "spend-sparrow/internal/treasure_chest_types"
templ Dashboard(treasureChests []*treasure_chest_types.TreasureChest) {
templ DashboardComp(treasureChests []*treasure_chest_types.TreasureChest) {
<div class="mt-10 h-full">
<div id="main-chart" class="h-96 mt-10"></div>
<div id="treasure-chests" class="h-96 mt-10"></div>

View File

@@ -1 +0,0 @@
package template