You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2017/02/08 15:27:20 UTC
[1/2] incubator-trafficcontrol git commit: This closes #263
Repository: incubator-trafficcontrol
Updated Branches:
refs/heads/master 91dd22724 -> 43e6d13c2
This closes #263
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/43e6d13c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/43e6d13c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/43e6d13c
Branch: refs/heads/master
Commit: 43e6d13c246e4467b22a60f0d883b82184d66ebe
Parents: d3fefc4
Author: Dewayne Richardson <de...@apache.org>
Authored: Wed Feb 8 08:27:09 2017 -0700
Committer: Dewayne Richardson <de...@apache.org>
Committed: Wed Feb 8 08:27:09 2017 -0700
----------------------------------------------------------------------
----------------------------------------------------------------------
[2/2] incubator-trafficcontrol git commit: adds more prefetches to
api endpoints
Posted by de...@apache.org.
adds more prefetches to api endpoints
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/d3fefc4b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/d3fefc4b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/d3fefc4b
Branch: refs/heads/master
Commit: d3fefc4b64868a6d3fc70123de5dad5af4863552
Parents: 91dd227
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Tue Feb 7 20:10:56 2017 -0700
Committer: Dewayne Richardson <de...@apache.org>
Committed: Wed Feb 8 08:27:09 2017 -0700
----------------------------------------------------------------------
traffic_ops/app/lib/API/Cachegroup.pm | 14 +++++++-------
traffic_ops/app/lib/API/DeliveryServiceRegexes.pm | 4 ++--
traffic_ops/app/lib/API/DeliveryServiceServer.pm | 2 +-
traffic_ops/app/lib/API/Deliveryservice.pm | 2 +-
traffic_ops/app/lib/API/PhysLocation.pm | 2 +-
traffic_ops/app/lib/API/Profile.pm | 2 +-
traffic_ops/app/lib/API/ProfileParameter.pm | 2 +-
traffic_ops/app/lib/API/Server.pm | 2 +-
traffic_ops/app/lib/API/StaticDnsEntry.pm | 2 +-
9 files changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d3fefc4b/traffic_ops/app/lib/API/Cachegroup.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Cachegroup.pm b/traffic_ops/app/lib/API/Cachegroup.pm
index 920ff88..1c09fcc 100644
--- a/traffic_ops/app/lib/API/Cachegroup.pm
+++ b/traffic_ops/app/lib/API/Cachegroup.pm
@@ -45,15 +45,15 @@ sub index {
$criteria{'type'} = $type_id;
}
- my $rs_data = $self->db->resultset("Cachegroup")->search( \%criteria, { prefetch => [ { 'type' => undef, } ], order_by => 'me.' . $orderby } );
+ my $rs_data = $self->db->resultset("Cachegroup")->search( \%criteria, { prefetch => [ 'type' ], order_by => 'me.' . $orderby } );
while ( my $row = $rs_data->next ) {
push(
@data, {
"id" => $row->id,
"name" => $row->name,
"shortName" => $row->short_name,
- "latitude" => 0.0 + $row->latitude,
- "longitude" => 0.0 + $row->longitude,
+ "latitude" => defined($row->latitude) ? 0.0 + $row->latitude : undef,
+ "longitude" => defined($row->longitude) ? 0.0 + $row->longitude : undef,
"lastUpdated" => $row->last_updated,
"parentCachegroupId" => $row->parent_cachegroup_id,
"parentCachegroupName" => ( defined $row->parent_cachegroup_id ) ? $idnames{ $row->parent_cachegroup_id } : undef,
@@ -74,7 +74,7 @@ sub index_trimmed {
my @data;
my $orderby = $self->param('orderby') || "name";
- my $rs_data = $self->db->resultset("Cachegroup")->search( undef, { prefetch => [ { 'type' => undef, } ], order_by => 'me.' . $orderby } );
+ my $rs_data = $self->db->resultset("Cachegroup")->search( undef, { order_by => 'me.' . $orderby } );
while ( my $row = $rs_data->next ) {
push(
@data, {
@@ -89,7 +89,7 @@ sub show {
my $self = shift;
my $id = $self->param('id');
- my $rs_data = $self->db->resultset("Cachegroup")->search( { id => $id } );
+ my $rs_data = $self->db->resultset("Cachegroup")->search( { id => $id }, { prefetch => [ 'type' ] } );
my @data = ();
my %idnames;
@@ -105,8 +105,8 @@ sub show {
"id" => $row->id,
"name" => $row->name,
"shortName" => $row->short_name,
- "latitude" => 0.0 + $row->latitude,
- "longitude" => 0.0 + $row->longitude,
+ "latitude" => defined($row->latitude) ? 0.0 + $row->latitude : undef,
+ "longitude" => defined($row->longitude) ? 0.0 + $row->longitude : undef,
"lastUpdated" => $row->last_updated,
"parentCachegroupId" => $row->parent_cachegroup_id,
"parentCachegroupName" => ( defined $row->parent_cachegroup_id ) ? $idnames{ $row->parent_cachegroup_id } : undef,
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d3fefc4b/traffic_ops/app/lib/API/DeliveryServiceRegexes.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/DeliveryServiceRegexes.pm b/traffic_ops/app/lib/API/DeliveryServiceRegexes.pm
index b5edb91..464390a 100644
--- a/traffic_ops/app/lib/API/DeliveryServiceRegexes.pm
+++ b/traffic_ops/app/lib/API/DeliveryServiceRegexes.pm
@@ -69,7 +69,7 @@ sub index {
my %criteria;
$criteria{'deliveryservice'} = $ds_id;
- my $rs_data = $self->db->resultset("DeliveryserviceRegex")->search( \%criteria, { order_by => 'me.set_number' } );
+ my $rs_data = $self->db->resultset("DeliveryserviceRegex")->search( \%criteria, { prefetch => [ { 'regex' => 'type' } ], order_by => 'me.set_number' } );
my @data = ();
while ( my $row = $rs_data->next ) {
push(
@@ -99,7 +99,7 @@ sub show {
$criteria{'deliveryservice'} = $ds_id;
$criteria{'regex'} = $regex_id;
- my $rs_data = $self->db->resultset("DeliveryserviceRegex")->search( \%criteria );
+ my $rs_data = $self->db->resultset("DeliveryserviceRegex")->search( \%criteria, { prefetch => [ { 'regex' => 'type' } ] } );
my @data = ();
while ( my $row = $rs_data->next ) {
push(
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d3fefc4b/traffic_ops/app/lib/API/DeliveryServiceServer.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/DeliveryServiceServer.pm b/traffic_ops/app/lib/API/DeliveryServiceServer.pm
index a142809..441a20a 100644
--- a/traffic_ops/app/lib/API/DeliveryServiceServer.pm
+++ b/traffic_ops/app/lib/API/DeliveryServiceServer.pm
@@ -30,7 +30,7 @@ sub index {
# defaulted pagination and limits because there are 38129 rows in this table and counting...
my $page = $self->param('page') || 1;
my $limit = $self->param('limit') || 20;
- my $rs_data = $self->db->resultset("DeliveryserviceServer")->search( undef, { page => $page, rows => $limit, order_by => $orderby } );
+ my $rs_data = $self->db->resultset("DeliveryserviceServer")->search( undef, { prefetch => [ 'deliveryservice', 'server' ], page => $page, rows => $limit, order_by => $orderby } );
while ( my $row = $rs_data->next ) {
push(
@data, {
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d3fefc4b/traffic_ops/app/lib/API/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Deliveryservice.pm b/traffic_ops/app/lib/API/Deliveryservice.pm
index a175ca5..d14b1a4 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -717,7 +717,7 @@ sub routing {
if ( $self->is_valid_delivery_service($id) ) {
if ( $self->is_delivery_service_assigned($id) || &is_admin($self) || &is_oper($self) ) {
- my $result = $self->db->resultset("Deliveryservice")->search( { 'me.id' => $id }, { prefetch => ['cdn'] } )->single();
+ my $result = $self->db->resultset("Deliveryservice")->search( { 'me.id' => $id }, { prefetch => [ 'cdn', 'type' ] } )->single();
my $cdn_name = $result->cdn->name;
# we expect type to be a dns or http type, but strip off any trailing bit
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d3fefc4b/traffic_ops/app/lib/API/PhysLocation.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/PhysLocation.pm b/traffic_ops/app/lib/API/PhysLocation.pm
index ed5d0bb..54c597d 100644
--- a/traffic_ops/app/lib/API/PhysLocation.pm
+++ b/traffic_ops/app/lib/API/PhysLocation.pm
@@ -97,7 +97,7 @@ sub index_trimmed {
my $self = shift;
my @data;
my $orderby = $self->param('orderby') || "name";
- my $rs_data = $self->db->resultset("PhysLocation")->search( undef, { prefetch => ['region'], order_by => 'me.' . $orderby } );
+ my $rs_data = $self->db->resultset("PhysLocation")->search( undef, { order_by => 'me.' . $orderby } );
while ( my $row = $rs_data->next ) {
next if $row->short_name eq 'UNDEF';
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d3fefc4b/traffic_ops/app/lib/API/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Profile.pm b/traffic_ops/app/lib/API/Profile.pm
index cca2a81..b41b835 100644
--- a/traffic_ops/app/lib/API/Profile.pm
+++ b/traffic_ops/app/lib/API/Profile.pm
@@ -30,7 +30,7 @@ sub index {
my $parameter_id = $self->param('param');
if ( defined $parameter_id ) {
- my $rs = $self->db->resultset('ProfileParameter')->search( { parameter => $parameter_id }, { order_by => $orderby } );
+ my $rs = $self->db->resultset('ProfileParameter')->search( { parameter => $parameter_id }, { prefetch => [ 'profile' ], order_by => $orderby } );
while ( my $row = $rs->next ) {
push(
@data, {
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d3fefc4b/traffic_ops/app/lib/API/ProfileParameter.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/ProfileParameter.pm b/traffic_ops/app/lib/API/ProfileParameter.pm
index c94c897..0113977 100644
--- a/traffic_ops/app/lib/API/ProfileParameter.pm
+++ b/traffic_ops/app/lib/API/ProfileParameter.pm
@@ -27,7 +27,7 @@ sub index {
my @data;
my $orderby = "profile";
$orderby = $self->param('orderby') if ( defined $self->param('orderby') );
- my $rs_data = $self->db->resultset("ProfileParameter")->search( undef, { order_by => $orderby } );
+ my $rs_data = $self->db->resultset("ProfileParameter")->search( undef, { prefetch => [ 'profile' ], order_by => $orderby } );
while ( my $row = $rs_data->next ) {
push(
@data, {
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d3fefc4b/traffic_ops/app/lib/API/Server.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Server.pm b/traffic_ops/app/lib/API/Server.pm
index afcaf9d..402e016 100644
--- a/traffic_ops/app/lib/API/Server.pm
+++ b/traffic_ops/app/lib/API/Server.pm
@@ -126,7 +126,7 @@ sub show {
my $self = shift;
my $id = $self->param('id');
- my $rs_data = $self->db->resultset("Server")->search( { id => $id } );
+ my $rs_data = $self->db->resultset("Server")->search( { id => $id }, { prefetch => [ 'cachegroup', 'cdn', 'phys_location', 'profile', 'status', 'type' ]} );
my @data = ();
my $is_admin = &is_admin($self);
while ( my $row = $rs_data->next ) {
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d3fefc4b/traffic_ops/app/lib/API/StaticDnsEntry.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/StaticDnsEntry.pm b/traffic_ops/app/lib/API/StaticDnsEntry.pm
index 938c2b4..3ce4f43 100644
--- a/traffic_ops/app/lib/API/StaticDnsEntry.pm
+++ b/traffic_ops/app/lib/API/StaticDnsEntry.pm
@@ -25,7 +25,7 @@ sub index {
my @data;
my $orderby = $self->param('orderby') || "deliveryservice";
- my $rs_data = $self->db->resultset("Staticdnsentry")->search( undef, { order_by => 'me.' . $orderby } );
+ my $rs_data = $self->db->resultset("Staticdnsentry")->search( undef, { prefetch => [ 'deliveryservice', 'type', 'cachegroup' ], order_by => 'me.' . $orderby } );
while ( my $row = $rs_data->next ) {
push(
@data, {