[refactor] template handling
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-11-28 20:05:50 -05:00
parent bb837dd30e
commit 756db7a493
29 changed files with 851 additions and 972 deletions

View File

@@ -1,6 +1,7 @@
package api
import (
"errors"
"fmt"
"math"
@@ -95,3 +96,18 @@ func getSVGGraphData(inputData []database.GetDailyReadStatsRow, svgWidth int, sv
return graph.GetSVGGraphData(intData, svgWidth, svgHeight)
}
func dict(values ...interface{}) (map[string]interface{}, error) {
if len(values)%2 != 0 {
return nil, errors.New("invalid dict call")
}
dict := make(map[string]interface{}, len(values)/2)
for i := 0; i < len(values); i += 2 {
key, ok := values[i].(string)
if !ok {
return nil, errors.New("dict keys must be strings")
}
dict[key] = values[i+1]
}
return dict, nil
}