Compare commits

...

2 Commits

Author SHA1 Message Date
2839a2c4c3 chore(deps): update golang:1.25.3 docker digest to 6d4e5e7
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 1m25s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 1m32s
2025-11-05 06:05:58 +00:00
d3ce7d5ac3 fix: new linting errors
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 1m34s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 1m33s
2025-11-05 07:00:49 +01:00
3 changed files with 21 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
FROM golang:1.25.3@sha256:7e3cbcd2f6af1bebb937462ec29f77ce28b406081af509afed158fa8721f11af AS builder_go
FROM golang:1.25.3@sha256:6d4e5e74f47db00f7f24da5f53c1b4198ae46862a47395e30477365458347bf2 AS builder_go
WORKDIR /spend-sparrow
RUN go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
RUN go install github.com/a-h/templ/cmd/templ@latest

View File

@@ -8,6 +8,7 @@ import (
"spend-sparrow/internal/service"
"spend-sparrow/internal/template/dashboard"
"spend-sparrow/internal/utils"
"strings"
"time"
"github.com/google/uuid"
@@ -74,14 +75,17 @@ func (handler DashboardImpl) handleDashboardMainChart() http.HandlerFunc {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
account := ""
savings := ""
accountBuilder := strings.Builder{}
savingsBuilder := strings.Builder{}
for _, entry := range series {
account += fmt.Sprintf(`["%s",%.2f],`, entry.Day.Format(time.RFC3339), float64(entry.Value)/100)
savings += fmt.Sprintf(`["%s",%.2f],`, entry.Day.Format(time.RFC3339), float64(entry.Savings)/100)
accountBuilder.WriteString(fmt.Sprintf(`["%s",%.2f],`, entry.Day.Format(time.RFC3339), float64(entry.Value)/100))
savingsBuilder.WriteString(fmt.Sprintf(`["%s",%.2f],`, entry.Day.Format(time.RFC3339), float64(entry.Savings)/100))
}
account := accountBuilder.String()
savings := savingsBuilder.String()
account = account[:len(account)-1]
savings = savings[:len(savings)-1]
@@ -137,23 +141,24 @@ func (handler DashboardImpl) handleDashboardTreasureChests() http.HandlerFunc {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
data := ""
dataBuilder := strings.Builder{}
for _, item := range treeList {
children := ""
childrenBuilder := strings.Builder{}
for _, child := range item.Children {
if child.Value < 0 {
children += fmt.Sprintf(`{"name":"%s\n%.2f €","value":%d},`, child.Name, float64(child.Value)/100, -child.Value)
childrenBuilder.WriteString(fmt.Sprintf(`{"name":"%s\n%.2f €","value":%d},`, child.Name, float64(child.Value)/100, -child.Value))
} else {
children += fmt.Sprintf(`{"name":"%s\n%.2f €","value":%d},`, child.Name, float64(child.Value)/100, child.Value)
childrenBuilder.WriteString(fmt.Sprintf(`{"name":"%s\n%.2f €","value":%d},`, child.Name, float64(child.Value)/100, child.Value))
}
}
children := childrenBuilder.String()
children = children[:len(children)-1]
data += fmt.Sprintf(`{"name":"%s","children":[%s]},`, item.Name, children)
dataBuilder.WriteString(fmt.Sprintf(`{"name":"%s","children":[%s]},`, item.Name, children))
}
data := dataBuilder.String()
data = data[:len(data)-1]
_, err = fmt.Fprintf(w, `
@@ -204,12 +209,14 @@ func (handler DashboardImpl) handleDashboardTreasureChest() http.HandlerFunc {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
value := ""
valueBuilder := strings.Builder{}
for _, entry := range series {
value += fmt.Sprintf(`["%s",%.2f],`, entry.Day.Format(time.RFC3339), float64(entry.Value)/100)
valueBuilder.WriteString(fmt.Sprintf(`["%s",%.2f],`, entry.Day.Format(time.RFC3339), float64(entry.Value)/100))
}
value := valueBuilder.String()
if len(value) > 0 {
value = value[:len(value)-1]
}

View File

@@ -152,7 +152,7 @@ func getTokenAttribute(t *testing.T, data *html.Node) string {
for _, attr := range data.Attr {
if attr.Key == "hx-headers" {
var data map[string]interface{}
var data map[string]any
err := json.Unmarshal([]byte(attr.Val), &data)
require.NoError(t, err)
result, ok := data["Csrf-Token"].(string)