From: levinse Date: Tue, 21 Jun 2011 22:00:32 +0000 (+0000) Subject: improve performance of DID provisioning status report, RT10988 X-Git-Tag: freeside_2_3_0~97 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=fb8915cce4be9520c00cc53c659e34abfb6172e1 improve performance of DID provisioning status report, RT10988 --- diff --git a/httemplate/search/phone_inventory_provisioned.html b/httemplate/search/phone_inventory_provisioned.html index 6302144f8..37fef8a21 100644 --- a/httemplate/search/phone_inventory_provisioned.html +++ b/httemplate/search/phone_inventory_provisioned.html @@ -34,20 +34,21 @@ return scalar(@dids); }, sub { # Have Usage - my $latanum = shift->latanum; - my @dids = provisioned_dids($latanum); - - warn "have usage ".time; - return ''; # XXX disabled temporarily + my $did_order = shift; + my @dids = provisioned_dids($did_order->latanum); my $count = 0; foreach my $did ( @dids ) { - next unless $did->cust_svc; - my $svc_phone = $did->cust_svc->svc_x; - warn "inside loop ".time; - next unless $svc_phone; - my @cdrs = $svc_phone->get_cdrs; - $count++ if scalar(@cdrs); + my $cust_svc = $did->cust_svc; + next unless $cust_svc; + + my $svcnum = $cust_svc->svcnum; + my $sql = "select count(1) from cdr where src = + (select phonenum from svc_phone where svcnum = $svcnum) + or charged_party = (select phonenum from svc_phone where + svcnum = $svcnum)"; + my $c = $did_order->scalar_sql($sql); + $count++ if $c > 0; } $count; },