Changeset 625


Ignore:
Timestamp:
10/08/14 16:25:51 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Commit 1/mumble for work done intermittently over the past ~year.
See #5, comment 25:

  • Update IPDB::listSummary() for new DB structure
File:
1 edited

Legend:

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

    r591 r625  
    424424  my $dbh = shift;
    425425
    426   my $mlist = $dbh->selectall_arrayref("SELECT cidr AS master FROM masterblocks ORDER BY cidr", { Slice => {} });
     426  my $mlist = $dbh->selectall_arrayref("SELECT cidr AS master,id,vrf FROM allocations ".
     427        "WHERE type='mm' ORDER BY cidr",
     428        { Slice => {} });
    427429
    428430  foreach (@{$mlist}) {
    429     my ($rcnt) = $dbh->selectrow_array("SELECT count(*) FROM allocations WHERE cidr <<= ? AND type='rm'",
    430         undef, ($$_{master}));
     431    my ($rcnt) = $dbh->selectrow_array("SELECT count(*) FROM allocations WHERE cidr <<= ? AND type='rm' AND master_id = ?",
     432        undef, ($$_{master}, $$_{id}));
    431433    $$_{routed} = $rcnt;
    432     my ($acnt) = $dbh->selectrow_array("SELECT count(*) FROM allocations WHERE cidr <<= ? AND NOT type='rm'",
    433         undef, ($$_{master}));
     434    my ($acnt) = $dbh->selectrow_array("SELECT count(*) FROM allocations WHERE cidr <<= ? ".
     435        "AND NOT type='rm' AND NOT type='mm' AND master_id = ?",
     436        undef, ($$_{master}, $$_{id}));
    434437    $$_{allocated} = $acnt;
    435     my ($fcnt) = $dbh->selectrow_array("SELECT count(*) FROM freeblocks WHERE cidr <<= ?",
    436         undef, ($$_{master}));
     438    my ($fcnt) = $dbh->selectrow_array("SELECT count(*) FROM freeblocks WHERE cidr <<= ? AND master_id = ?",
     439        undef, ($$_{master}, $$_{id}));
    437440    $$_{free} = $fcnt;
    438441    my ($bigfree) = $dbh->selectrow_array("SELECT masklen(cidr) AS maskbits FROM freeblocks WHERE cidr <<= ?".
    439         " AND parent = ? ORDER BY masklen(cidr) LIMIT 1", undef, ($$_{master}, $$_{master}));
     442        " AND master_id = ? ORDER BY masklen(cidr) LIMIT 1", undef, ($$_{master}, $$_{id}));
    440443##fixme:  should find a way to do this without having to HTMLize the <>
    441444    $bigfree = "/$bigfree" if $bigfree;
Note: See TracChangeset for help on using the changeset viewer.