rob05c commented on a change in pull request #4942:
URL: https://github.com/apache/trafficcontrol/pull/4942#discussion_r485182652
##########
File path: traffic_ops/traffic_ops_golang/steeringtargets/steeringtargets.go
##########
@@ -268,6 +276,22 @@ func (st *TOSteeringTargetV11) Update() (error, error,
int) {
return nil, nil, http.StatusOK
}
+func CheckIfExistsBeforeUpdate(tx *sqlx.Tx, st *TOSteeringTargetV11) (error,
*tc.TimeNoMod) {
+ lastUpdated := tc.TimeNoMod{}
+ rows, err := tx.NamedQuery(`select last_updated from steering_target
where deliveryservice=:deliveryservice and target=:target`, st)
+ if err != nil {
+ return err, nil
+ }
+ defer rows.Close()
+ if !rows.Next() {
+ return errors.New("no server found with this id"), nil
+ }
+ if err := rows.Scan(&lastUpdated); err != nil {
+ return err, nil
Review comment:
Debugging context, `return nil, errors.New("scanning: " + err.Error())`
##########
File path: traffic_ops/traffic_ops_golang/steeringtargets/steeringtargets.go
##########
@@ -268,6 +276,22 @@ func (st *TOSteeringTargetV11) Update() (error, error,
int) {
return nil, nil, http.StatusOK
}
+func CheckIfExistsBeforeUpdate(tx *sqlx.Tx, st *TOSteeringTargetV11) (error,
*tc.TimeNoMod) {
+ lastUpdated := tc.TimeNoMod{}
+ rows, err := tx.NamedQuery(`select last_updated from steering_target
where deliveryservice=:deliveryservice and target=:target`, st)
+ if err != nil {
+ return err, nil
Review comment:
Debugging context, `return nil, errors.New("querying: " + err.Error())`
----------------------------------------------------------------
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]