rawlinp commented on a change in pull request #2029: [Issue 1907] TO API for 
backup edge cachegroup
URL: 
https://github.com/apache/incubator-trafficcontrol/pull/2029#discussion_r190972947
 
 

 ##########
 File path: traffic_ops/traffic_ops_golang/crconfig/edgelocations.go
 ##########
 @@ -57,6 +57,36 @@ and (st.name = 'REPORTED' or st.name = 'ONLINE' or st.name 
= 'ADMIN_DOWN')
                if ttype == RouterTypeName {
                        routerLocs[cachegroup] = latlon
                } else {
+                       primaryCacheId := ""
+                       if err := db.QueryRow(`select id from cachegroup where 
name = $1`, cachegroup).Scan(&primaryCacheId); err != nil {
+                               return nil, nil, errors.New("Failed while 
retrieving from cachegroup: " + err.Error())
+                       }
+
+                       dbRows, err := db.Query(`select backup_cg from 
cachegroup_fallbacks where primary_cg = $1 order by set_order`, primaryCacheId)
 
 Review comment:
   you can use a `join` here and remove the extra query on L79:
   ```
   select cgf.backup_cg, c.name from cachegroup_fallbacks cgf join cachegroup c 
on c.id = cgf.backup_cg
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to