Fix product performance grouped JSON build
This commit is contained in:
@@ -273,6 +273,13 @@ func GetProductPerformanceGroupedHandler(pg *sql.DB) http.HandlerFunc {
|
||||
groupLevels := splitCSVQuery(r.URL.Query().Get("group_levels"))
|
||||
limit := intQuery(r, "limit", 50000)
|
||||
expanded := map[string]bool{}
|
||||
const maxExpandedGroupKeys = 200
|
||||
addExpandedKey := func(key string) {
|
||||
key = strings.TrimSpace(key)
|
||||
if key != "" && len(expanded) < maxExpandedGroupKeys {
|
||||
expanded[key] = true
|
||||
}
|
||||
}
|
||||
if r.Method == http.MethodPost {
|
||||
var body struct {
|
||||
Mode string `json:"mode"`
|
||||
@@ -298,17 +305,11 @@ func GetProductPerformanceGroupedHandler(pg *sql.DB) http.HandlerFunc {
|
||||
limit = body.Limit
|
||||
}
|
||||
for _, key := range body.ExpandedKeys {
|
||||
key = strings.TrimSpace(key)
|
||||
if key != "" {
|
||||
expanded[key] = true
|
||||
}
|
||||
addExpandedKey(key)
|
||||
}
|
||||
} else {
|
||||
for _, key := range strings.Split(r.URL.Query().Get("expanded_keys"), ",") {
|
||||
key = strings.TrimSpace(key)
|
||||
if key != "" {
|
||||
expanded[key] = true
|
||||
}
|
||||
addExpandedKey(key)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user