Changeset 653 for trunk/cgi-bin


Ignore:
Timestamp:
12/17/14 18:04:01 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Extend listSubs() to include some details on container blocks when
appropriate. Not sure this format will work; it ends up looking very
busy and confused after importing a dataset from IPDB 2.8. Consider
splitting containers vs direct allocations (so that there would be
three main page sections, not two).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r652 r653  
    500500  my $custsth = $dbh->prepare("SELECT count(*) FROM customers WHERE custid = ?");
    501501
     502  # snag some more details
     503  my $substh = $dbh->prepare("SELECT count(*) FROM allocations WHERE cidr <<= ? AND type='rm' AND master_id = ? AND NOT cidr = ? ");
     504  my $alsth = $dbh->prepare("SELECT count(*) FROM allocations WHERE cidr <<= ? ".
     505        "AND NOT type='rm' AND NOT type='mm' AND master_id = ?");
     506  my $freesth = $dbh->prepare("SELECT count(*) FROM freeblocks WHERE cidr <<= ? AND master_id = ?");
     507  my $lfreesth = $dbh->prepare("SELECT masklen(cidr) AS maskbits FROM freeblocks WHERE cidr <<= ?".
     508        " AND master_id = ? ORDER BY masklen(cidr) LIMIT 1");
     509
    502510  my @blocklist;
    503   while (my ($cidr,$city,$type,$custid,$swip,$desc,$id) = $sth->fetchrow_array()) {
     511  while (my ($cidr,$city,$type,$custid,$swip,$desc,$id,$mid) = $sth->fetchrow_array()) {
    504512    $custsth->execute($custid);
    505513    my ($ncust) = $custsth->fetchrow_array();
     514    $substh->execute($cidr, $mid, $cidr);
     515    my ($cont) = $substh->fetchrow_array();
     516    $alsth->execute($cidr, $mid);
     517    my ($alloc) = $alsth->fetchrow_array();
     518    $freesth->execute($cidr, $mid);
     519    my ($free) = $freesth->fetchrow_array();
     520    $lfreesth->execute($cidr, $mid);
     521    my ($lfree) = $lfreesth->fetchrow_array();
     522    $lfree = "/$lfree" if $lfree;
     523    $lfree = '<NONE>' if !$lfree;
    506524    my %row = (
    507525        block => $cidr,
     526        subcontainers => $cont,
     527        suballocs => $alloc,
     528        subfree => $free,
     529        lfree => $lfree,
    508530        city => $city,
    509531        type => $disp_alloctypes{$type},
Note: See TracChangeset for help on using the changeset viewer.