You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by el...@apache.org on 2017/07/12 19:10:15 UTC

[1/2] incubator-trafficcontrol git commit: update for new steeringtarget schema

Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/master 7a9a5b3cf -> 2df129a2f


update for new steeringtarget schema


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/6b47ae64
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/6b47ae64
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/6b47ae64

Branch: refs/heads/master
Commit: 6b47ae64cf4df205770b7f520a4923c895162bc7
Parents: 7a9a5b3
Author: Derek Gelinas <de...@cable.comcast.com>
Authored: Wed Jul 12 16:49:28 2017 +0000
Committer: Jeff Elsloo <je...@cable.comcast.com>
Committed: Wed Jul 12 13:09:54 2017 -0600

----------------------------------------------------------------------
 traffic_ops/app/lib/UI/Steering.pm | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/6b47ae64/traffic_ops/app/lib/UI/Steering.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Steering.pm b/traffic_ops/app/lib/UI/Steering.pm
index 197c7f6..1e7f98b 100644
--- a/traffic_ops/app/lib/UI/Steering.pm
+++ b/traffic_ops/app/lib/UI/Steering.pm
@@ -17,6 +17,7 @@ package UI::Steering;
 #
 
 # JvD Note: you always want to put Utils as the first use. Sh*t don't work if it's after the Mojo lines.
+use strict;
 use UI::Utils;
 use Mojo::Base 'Mojolicious::Controller';
 use Mojo::Parameters;
@@ -39,10 +40,10 @@ sub index {
 
 	#get the target delivery service IDs to pass to get_deliveryservices
 	my @targets;
-	foreach my $i ( keys @steering ) {
-		push ( @targets, $steering[$i]->{'target_id'} );
+	foreach my $steering ( @steering ) {
+		push ( @targets, $steering->{'target_id'} );
 	}
-
+	
 	my %ds_data = $self->get_deliveryservices($ds_id, \@targets);
 
 	&navbarpage($self);
@@ -89,8 +90,8 @@ sub get_target_data {
 		my $i = 0;
 		while ( my $row = $target_rs->next ) {
 			my $t = $steering_obj->{"target_$i"};
-			$t->{'target_id'} = $row->target;
-			$t->{'target_name'}   = $self->get_ds_name( $row->target );
+			$t->{'target_id'} = $row->target->id;
+			$t->{'target_name'}   = $self->get_ds_name( $row->target->id );
 			$t->{'target_value'}   = $row->value;
 			if (!defined($t->{'target_value'})) { $t->{'target_value'} = 0; }
 			$t->{'target_type'}   = $row->type->id;
@@ -172,7 +173,7 @@ sub update {
 	}
 	#validate the array, then replace the data in the database with the array data.
 	if ( $self->is_valid(\@targets) ) {
-		#delete current entries
+		#delete current entries 
 		my $delete = $self->db->resultset('SteeringTarget')
 			->search( { deliveryservice => $ds_id } );
 		if ( defined($delete) ) {
@@ -180,12 +181,12 @@ sub update {
 		}
 		
 		#add new entries
-		foreach my $i ( keys @targets ) {
+		foreach my $target ( @targets ) {
 			my $insert = $self->db->resultset('SteeringTarget')->create(
 				{   deliveryservice => $ds_id,
-					target          => $targets[$i]->{'target_id'},
-					value           => $targets[$i]->{'target_value'},
-					type            => $targets[$i]->{'target_type'}
+					target          => $target->{'target_id'},
+					value           => $target->{'target_value'},
+					type            => $target->{'target_type'}
 				}
 			);
 			$insert->insert();
@@ -204,8 +205,8 @@ sub update {
 		my @steering = $self->get_target_data($ds_id, $type_ids);
 
 		my @targets;
-		foreach my $i ( keys @steering ) {
-			push ( @targets, $steering[$i]->{'target_id'} );
+		foreach my $steering ( @steering ) {
+			push ( @targets, $steering->{'target_id'} );
 		}
 
 		my %ds_data = $self->get_deliveryservices($ds_id, \@targets);
@@ -231,8 +232,8 @@ sub is_valid {
 	my @targets = @{$_[0]};
 	my %tracker;
 
-	foreach my $i ( keys @targets ) {
-		my $t = $targets[$i];
+	foreach my $target ( @targets ) {
+		my $t = $target;
 		my $t_name = $self->db->resultset('Type')->search( { id => "$t->{'target_type'}" } )->get_column('name')->single();
 		if ( $t_name eq "STEERING_ORDER" && $t->{'target_value'} ne int($t->{'target_value'})) {
 			$self->flash(message => "STEERING_ORDER values must be integers." );


[2/2] incubator-trafficcontrol git commit: This closes #725.

Posted by el...@apache.org.
This closes #725.


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/2df129a2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/2df129a2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/2df129a2

Branch: refs/heads/master
Commit: 2df129a2f1bf7a148335e676c84b6cc2112999e2
Parents: 6b47ae6
Author: Jeff Elsloo <je...@cable.comcast.com>
Authored: Wed Jul 12 13:10:06 2017 -0600
Committer: Jeff Elsloo <je...@cable.comcast.com>
Committed: Wed Jul 12 13:10:06 2017 -0600

----------------------------------------------------------------------

----------------------------------------------------------------------