rimashah25 commented on a change in pull request #5350:
URL: https://github.com/apache/trafficcontrol/pull/5350#discussion_r543601063



##########
File path: traffic_ops/traffic_ops_golang/dbhelpers/db_helpers.go
##########
@@ -1150,3 +1151,68 @@ func CheckOriginServerInCacheGroupTopology(tx *sql.Tx, 
dsID int, dsTopology stri
        }
        return nil, nil, http.StatusOK
 }
+
+//GetDSByCDNIdTopology return the id of delivery service based on cdn_id and 
topology_name
+func GetDSByCDNIdTopology(tx *sql.Tx, cdnId int, topology string) (error, 
[]int) {
+       dsId := []int64{}
+       q := `
+               SELECT COALESCE(ARRAY_AGG(id), '{}'::BIGINT[]) 
+               FROM deliveryservice
+               WHERE cdn_id=$1 AND topology=$2
+       `
+       err := tx.QueryRow(q, cdnId, topology).Scan(pq.Array(&dsId))
+       if err != nil {
+               return fmt.Errorf("querying delivery services: %s", err), nil
+       }
+       res := make([]int, len(dsId))
+       for i, id := range dsId {
+               res[i] = int(id)
+       }
+       return err, res
+}
+
+// CheckTopologyOrgServerCGInDSCG checks if ORG server are part of DS. IF they 
are then the user is not allowed to remove the ORG servers from the associated 
DS's topology
+func CheckTopologyOrgServerCGInDSCG(tx *sql.Tx, dsIDs []int, dsTopology 
string, topologyCGNames []string) (error, error, int) {
+       // get servers and respective cachegroup name that have ORG type for 
evert delivery service
+       q := `
+               SELECT d.xml_id, s.host_name, c.name 

Review comment:
       :(




----------------------------------------------------------------
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]


Reply via email to