Changeset 2113


Ignore:
Timestamp:
10/09/17 09:55:08 (7 years ago)
Author:
nanardon
Message:

Revert computing of zone matching: too costly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm

    r2100 r2113  
    1919 
    2020sub _object_table { 'nethost' } 
    21  
    22 sub _object_table_attributes_read { 'nethost_attributes_read' } 
    2321 
    2422sub _key_field { 'name' } 
     
    132130                multiple => 1, ro => 1, managed => 1, 
    133131                reference => 'netzone', 
     132                get => sub { 
     133                    my ($self) = @_; 
     134                    my $find = $self->base->db->prepare_cached(q{ 
     135                        select name from netzone where ikey in 
     136                        ( 
     137                        select netzone_attributes.okey from netzone_attributes join 
     138                        nethost_attributes_ips on netzone_attributes.attr='net' 
     139                            and  
     140                        nethost_attributes_ips.value::inet <<= 
     141                        netzone_attributes.value::inet 
     142                        where nethost_attributes_ips.okey = $1 
     143                        except 
     144                        select netzone_attributes.okey from netzone_attributes join 
     145                        nethost_attributes_ips on netzone_attributes.attr='netExclude' 
     146                            and nethost_attributes_ips.value::inet <<= netzone_attributes.value::inet 
     147                        where nethost_attributes_ips.okey = $1 
     148                        ) 
     149                        order by name 
     150                        }); 
     151                    $find->execute($self->object->get_attributes('ikey')); 
     152                    my @zones; 
     153                    while (my $res = $find->fetchrow_hashref) { 
     154                        push(@zones, $res->{name}); 
     155                    } 
     156                    return @zones ? [ @zones ] : undef; 
     157                }, 
    134158                label => l('NetZones'), 
    135159            }, 
Note: See TracChangeset for help on using the changeset viewer.