fix: new linting errors
This commit was merged in pull request #351.
This commit is contained in:
@@ -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]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user