fix: new linting errors #351
@@ -8,6 +8,7 @@ import (
|
|||||||
"spend-sparrow/internal/service"
|
"spend-sparrow/internal/service"
|
||||||
"spend-sparrow/internal/template/dashboard"
|
"spend-sparrow/internal/template/dashboard"
|
||||||
"spend-sparrow/internal/utils"
|
"spend-sparrow/internal/utils"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
@@ -74,14 +75,17 @@ func (handler DashboardImpl) handleDashboardMainChart() http.HandlerFunc {
|
|||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
|
||||||
account := ""
|
accountBuilder := strings.Builder{}
|
||||||
savings := ""
|
savingsBuilder := strings.Builder{}
|
||||||
|
|
||||||
for _, entry := range series {
|
for _, entry := range series {
|
||||||
account += fmt.Sprintf(`["%s",%.2f],`, entry.Day.Format(time.RFC3339), float64(entry.Value)/100)
|
accountBuilder.WriteString(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)
|
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]
|
account = account[:len(account)-1]
|
||||||
savings = savings[:len(savings)-1]
|
savings = savings[:len(savings)-1]
|
||||||
|
|
||||||
@@ -137,23 +141,24 @@ func (handler DashboardImpl) handleDashboardTreasureChests() http.HandlerFunc {
|
|||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
|
||||||
data := ""
|
dataBuilder := strings.Builder{}
|
||||||
|
|
||||||
for _, item := range treeList {
|
for _, item := range treeList {
|
||||||
children := ""
|
childrenBuilder := strings.Builder{}
|
||||||
|
|
||||||
for _, child := range item.Children {
|
for _, child := range item.Children {
|
||||||
if child.Value < 0 {
|
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 {
|
} 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]
|
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]
|
data = data[:len(data)-1]
|
||||||
|
|
||||||
_, err = fmt.Fprintf(w, `
|
_, err = fmt.Fprintf(w, `
|
||||||
@@ -204,12 +209,14 @@ func (handler DashboardImpl) handleDashboardTreasureChest() http.HandlerFunc {
|
|||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
|
||||||
value := ""
|
valueBuilder := strings.Builder{}
|
||||||
|
|
||||||
for _, entry := range series {
|
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 {
|
if len(value) > 0 {
|
||||||
value = value[:len(value)-1]
|
value = value[:len(value)-1]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ func getTokenAttribute(t *testing.T, data *html.Node) string {
|
|||||||
|
|
||||||
for _, attr := range data.Attr {
|
for _, attr := range data.Attr {
|
||||||
if attr.Key == "hx-headers" {
|
if attr.Key == "hx-headers" {
|
||||||
var data map[string]interface{}
|
var data map[string]any
|
||||||
err := json.Unmarshal([]byte(attr.Val), &data)
|
err := json.Unmarshal([]byte(attr.Val), &data)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
result, ok := data["Csrf-Token"].(string)
|
result, ok := data["Csrf-Token"].(string)
|
||||||
|
|||||||
Reference in New Issue
Block a user