Changeset 715 for trunk


Ignore:
Timestamp:
04/13/16 10:31:32 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Fine-tuning behaviour to support IPDB RPC calls

  • allow filtering record lists in getRecList on location as well
  • add option to getZonesByCIDR to leave out default_location field in return
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r714 r715  
    42004200  my $perpage = ($args{nrecs} ? $args{nrecs} : $self->{perpage});
    42014201
    4202 
    42034202##fixme:  do we need a knob to twist to switch from unix epoch to postgres time string?
    42044203  my @bindvars;
     
    42304229
    42314230  # Filtering on other fields
    4232   foreach (qw(type distance weight port ttl description)) {
     4231  foreach (qw(type distance weight port ttl description location)) {
    42334232    if ($args{$_}) {
    42344233      $sql .= " AND $_ ~* ?";
     
    51845183# Get a list of zone names and IDs that records for a passed CIDR block are within.
    51855184# Optionally restrict to a specific location/view
     5185# Optionally leave off the default_location field
    51865186sub getZonesByCIDR {
    51875187  my $self = shift;
    51885188  my $dbh = $self->{dbh};
    51895189  my %args = @_;
    5190 
    5191   my $sql = "SELECT rdns_id,revnet,default_location FROM revzones WHERE (revnet >>= ? OR revnet <<= ?)".
    5192         ($args{location} ? " AND default_location = ?" : '');
     5190  $args{return_location} = 1 if !defined($args{return_location});
     5191
     5192  my $sql = "SELECT rdns_id,revnet".($args{return_location} ? ',default_location' : '').
     5193        " FROM revzones WHERE (revnet >>= ? OR revnet <<= ?)".
     5194        (defined($args{location}) ? " AND default_location = ?" : '');
    51935195  my @svals = ($args{cidr}, $args{cidr});
    5194   push @svals, $args{location} if $args{location};
     5196  push @svals, $args{location} if defined $args{location};
    51955197
    51965198  my $result = $dbh->selectall_arrayref($sql, { Slice => {} }, @svals );
Note: See TracChangeset for help on using the changeset viewer.