all these DB queries and type-checking can be consolidated a bit like this (the
one query returns all the data you need in one go):
```
my $cachegroup = $self->db->resultset('Cachegroup')->search( {'me.id'
=> $server_obj->cachegroup->id }, { prefetch => [ { 'parent_cachegroup' =>
'type' }, { 'secondary_parent_cachegroup' => 'type' } ] })->single();
my $parent_type = defined($cachegroup->parent_cachegroup)?
$cachegroup->parent_cachegroup->type->name : '';
my $secondary_parent_type =
defined($cachegroup->secondary_parent_cachegroup)?
$cachegroup->secondary_parent_cachegroup->type->name : '';
if (($parent_type eq '' || $parent_type eq 'ORG_LOC')
&& ($secondary_parent_type eq '' ||
$secondary_parent_type eq 'ORG_LOC')) {
$is_top_level_cache = 1;
}
```
[ Full content available at: https://github.com/apache/trafficcontrol/pull/2904
]
This message was relayed via gitbox.apache.org for [email protected]