Changeset 925


Ignore:
Timestamp:
Jul 9, 2019, 4:28:38 PM (4 months ago)
Author:
kdeugau
Message:

/trunk

Extend search-rpc.cgi to support searching on the parent_id; other criteria
may not narrow things down enough

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/search-rpc.cgi

    r911 r925  
    224224  } # args{cidr}
    225225
    226   foreach (qw(custid description notes city) ) {
    227     if ($args{$_}) {
    228       push @fields, "s.$_";
    229       if ($args{$_} =~ /^(EXACT|NOT):/) {
     226  foreach my $sfield (qw(custid description notes city) ) {
     227    if ($args{$sfield}) {
     228      push @fields, "s.$sfield";
     229      if ($args{$sfield} =~ /^(EXACT|NOT):/) {
    230230        push @matchtypes, $mt{$1};
    231         $args{$_} =~ s/^$1://;
     231        $args{$sfield} =~ s/^$1://;
    232232      } else {
    233233        push @matchtypes, '~*';
    234234      }
    235       push @vals, $args{$_};
    236     }
     235      push @vals, $args{$sfield};
     236    }
     237  }
     238
     239  if ($args{parent_id}) {
     240    # parent_id is always exact.  default to positive match
     241    if ($args{parent_id} =~ /^NOT:/) {
     242      $args{parent_id} =~ s/^NOT://;
     243      push @matchtypes, '<>';
     244    } else {
     245      push @matchtypes, '=';
     246    }
     247    push @fields, 's.parent_id';
     248    push @vals, $args{parent_id};
    237249  }
    238250
     
    349361Not all fields are exposed for search.  For most purposes these should be sufficient.
    350362
     363Most fields support EXACT: or NOT: prefixes on the search term to restrict the matches.
     364
    351365=over 4
    352366
     
    413427To search for a free block, use the main RPC API's listFree or findAllocateFrom subs.
    414428
     429=item parent_id
     430
     431Restrict to allocations in the given parent.
     432
    415433=item order
    416434
Note: See TracChangeset for help on using the changeset viewer.