rimashah25 commented on code in PR #7291:
URL: https://github.com/apache/trafficcontrol/pull/7291#discussion_r1088161297


##########
traffic_ops/traffic_ops_golang/monitoring/monitoring.go:
##########
@@ -571,3 +542,46 @@ AND c.name = $3
        }
        return cfg, nil
 }
+
+func aggregateMultipleProfileParameters(tx *sql.Tx, profileNames []string) 
(map[string]map[string]interface{}, error) {
+       p := make(map[string]map[string]interface{})
+       query := `
+SELECT p.name, pr.name, pr.value
+FROM parameter pr
+JOIN profile p ON p.name = ANY($1)
+JOIN profile_parameter pp ON pp.profile = p.id and pp.parameter = pr.id
+WHERE pr.config_file = $2
+ORDER BY ARRAY_POSITION($1, p.name), pr.name;`
+
+       for _, profile := range profileNames {
+               profileList := strings.Split(profile, "+")
+               rows, err := tx.Query(query, pq.Array(profileList), 
CacheMonitorConfigFile)
+               if err != nil {
+                       return nil, err
+               }
+               defer rows.Close()
+
+               var parameter map[string]interface{}
+               for rows.Next() {
+                       var pName, prName, value string
+                       if err := rows.Scan(&pName, &prName, &value); err != 
nil {
+                               return nil, err
+                       }
+                       if prName == "" {
+                               return nil, fmt.Errorf("null name") // TODO 
continue and warn?
+                       }
+                       if parameter == nil {
+                               parameter = map[string]interface{}{}
+                       }

Review Comment:
   Left over code from previous owner, so didn't update it. But yeah we can do 
that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to