mattjackson220 commented on a change in pull request #4339: 
cachegroupparameters rewrite
URL: https://github.com/apache/trafficcontrol/pull/4339#discussion_r374353024
 
 

 ##########
 File path: traffic_ops/traffic_ops_golang/cachegroupparameter/parameters.go
 ##########
 @@ -180,3 +187,137 @@ func (cgparam *TOCacheGroupParameter) Delete() (error, 
error, int) {
 
        return api.GenericDelete(cgparam)
 }
+
+// ReadAllCacheGroupParameters reads all cachegroup parameter associations.
+func ReadAllCacheGroupParameters(w http.ResponseWriter, r *http.Request) {
+       inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil)
+       if userErr != nil || sysErr != nil {
+               api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
+               return
+       }
+       defer inf.Close()
+       output, err := GetAllCacheGroupParameters(inf.Tx, inf.Params)
+       if err != nil {
+               api.WriteRespAlertObj(w, r, tc.ErrorLevel, "querying 
cachegroupparameters with error: "+err.Error(), output)
+               return
+       }
+       api.WriteResp(w, r, output)
+}
+
+// GetAllCacheGroupParameters gets all cachegroup associations from the 
database and returns as slice.
+func GetAllCacheGroupParameters(tx *sqlx.Tx, parameters map[string]string) 
(tc.CacheGroupParametersList, error) {
+       if _, ok := parameters["orderby"]; !ok {
+               parameters["orderby"] = "cachegroup"
+       }
+
+       // Query Parameters to Database Query column mappings
+       // see the fields mapped in the SQL query
+       queryParamsToQueryCols := map[string]dbhelpers.WhereColumnInfo{
+               "cachegroup": dbhelpers.WhereColumnInfo{"cgp.cachegroup", 
api.IsInt},
+               "parameter":  dbhelpers.WhereColumnInfo{"cgp.parameter", 
api.IsInt},
+       }
+
+       where, orderBy, pagination, queryValues, errs := 
dbhelpers.BuildWhereAndOrderByAndPagination(parameters, queryParamsToQueryCols)
+       if len(errs) > 0 {
+               return tc.CacheGroupParametersList{}, util.JoinErrs(errs)
+       }
+
+       log.Errorf("MATT JACKSON queryparams = %s", queryValues)
+       log.Errorf("MATT JACKSON parameters = %s", parameters)
+       log.Errorf("MATT JACKSON query = %s", 
selectAllQuery()+where+orderBy+pagination)
 
 Review comment:
   well thats embarrassing. done

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to