[freeside-commits] branch FREESIDE_4_BRANCH updated. e19b24a18d4489ed0ea8c6624ba76364a933c868
Ivan
ivan at 420.am
Mon Mar 28 17:29:37 PDT 2016
The branch, FREESIDE_4_BRANCH has been updated
via e19b24a18d4489ed0ea8c6624ba76364a933c868 (commit)
from 18478e91f04d3e7bc2e846a20ade57f41ba80011 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e19b24a18d4489ed0ea8c6624ba76364a933c868
Author: Ivan Kohler <ivan at freeside.biz>
Date: Mon Mar 28 17:29:36 2016 -0700
optimize customer list, RT#30173
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 78bb6cb..3de04f0 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -4031,13 +4031,17 @@ sub status { shift->cust_status(@_); }
sub cust_status {
my $self = shift;
+ return $self->hashref->{cust_status} if $self->hashref->{cust_status};
for my $status ( FS::cust_main->statuses() ) {
my $method = $status.'_sql';
my $numnum = ( my $sql = $self->$method() ) =~ s/cust_main\.custnum/?/g;
my $sth = dbh->prepare("SELECT $sql") or die dbh->errstr;
$sth->execute( ($self->custnum) x $numnum )
or die "Error executing 'SELECT $sql': ". $sth->errstr;
- return $status if $sth->fetchrow_arrayref->[0];
+ if ( $sth->fetchrow_arrayref->[0] ) {
+ $self->hashref->{cust_status} = $status;
+ return $status;
+ }
}
}
diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi
index e6ab195..c501c50 100755
--- a/httemplate/search/cust_main.cgi
+++ b/httemplate/search/cust_main.cgi
@@ -120,11 +120,18 @@
% foreach my $cust_pkg ( @{$all_pkgs{$custnum}} ) {
% my %cust_svc_by_svcpart;
% my $rows = 0;
-% local($FS::part_pkg::cache_enabled) = 1; #for $cust_pkg->part_svc
+% #local($FS::part_pkg::cache_enabled) = 1; #for $cust_pkg->part_svc
% local($FS::cust_svc::cache_enabled) = 1; #for $cust_svc->part_svc
-% local($FS::pkg_svc::cache_enabled) = 1; #for $pkg_svc->part_svc
+% #local($FS::pkg_svc::cache_enabled) = 1; #for $pkg_svc->part_svc
% foreach my $part_svc (
-% $cust_pkg->part_svc( summarize_size=>$large_pkg_size )
+% #$cust_pkg->part_svc( summarize_size=>$large_pkg_size )
+% qsearch({
+% 'select' => 'part_svc.*, COUNT(*) AS num_cust_svc',
+% 'table' => 'part_svc',
+% 'addl_from' => 'LEFT JOIN cust_svc USING ( svcpart )',
+% 'extra_sql' => 'WHERE pkgnum = ? GROUP BY part_svc.svcpart',
+% 'extra_param' => [ [$cust_pkg->pkgnum,'int'] ],
+% })
% ) {
% my $svcpart = $part_svc->svcpart;
% my $num_cust_svc = $part_svc->num_cust_svc;
@@ -136,7 +143,9 @@
% $rows += 2;
% }
% elsif ( $num_cust_svc ) {
-% $cust_svc_by_svcpart{$svcpart} = $part_svc->cust_pkg_svc;
+% #$cust_svc_by_svcpart{$svcpart} = $part_svc->cust_pkg_svc;
+% #further optimization opportunities: don't need to re-pull in another $part_svc object, sorting this is expensive, etc.
+% $cust_svc_by_svcpart{$svcpart} = [ $cust_pkg->cust_svc($part_svc->svcpart) ];
% $rows += $num_cust_svc;
% } #if summarize
% } #foreach $part_svc
@@ -236,6 +245,7 @@
% my $n1 = '';
% foreach ( @{$all_pkgs{$custnum}} ) {
+% local($FS::cust_svc::cache_enabled) = 1; #for $cust_svc->part_svc
% my $pkgnum = $_->pkgnum;
% my $part_pkg = $_->part_pkg;
%
-----------------------------------------------------------------------
Summary of changes:
FS/FS/cust_main.pm | 6 +++++-
httemplate/search/cust_main.cgi | 18 ++++++++++++++----
2 files changed, 19 insertions(+), 5 deletions(-)
More information about the freeside-commits
mailing list