1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

refactor: minor code refactorings

This commit is contained in:
Ferdinand Mütsch
2022-12-29 11:54:14 +01:00
parent 8ca1404f8b
commit bafbc34706
14 changed files with 124 additions and 112 deletions

View File

@@ -5,6 +5,7 @@ import (
"github.com/muety/wakapi/models"
"github.com/muety/wakapi/services"
"net/http"
"strings"
)
func LoadUserSummary(ss services.ISummaryService, r *http.Request) (*models.Summary, error, int) {
@@ -38,3 +39,13 @@ func LoadUserSummaryByParams(ss services.ISummaryService, params *models.Summary
return summary, nil, http.StatusOK
}
func FilterColors(all map[string]string, haystack models.SummaryItems) map[string]string {
subset := make(map[string]string)
for _, item := range haystack {
if c, ok := all[strings.ToLower(item.Key)]; ok {
subset[strings.ToLower(item.Key)] = c
}
}
return subset
}