[freeside-commits] branch FREESIDE_3_BRANCH updated. d71e1c5319b4a2f0092f0e64da1638df57162dba
Ivan
ivan at 420.am
Wed Mar 23 21:05:37 PDT 2016
The branch, FREESIDE_3_BRANCH has been updated
via d71e1c5319b4a2f0092f0e64da1638df57162dba (commit)
from f90f0685f9855a840c8e49c895dcce1ce0752ae0 (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 d71e1c5319b4a2f0092f0e64da1638df57162dba
Author: Ivan Kohler <ivan at freeside.biz>
Date: Wed Mar 23 21:05:34 2016 -0700
optimize customer list, RT#20173
diff --git a/FS/FS/cust_main/Packages.pm b/FS/FS/cust_main/Packages.pm
index 7b71eb2..03d9bab 100644
--- a/FS/FS/cust_main/Packages.pm
+++ b/FS/FS/cust_main/Packages.pm
@@ -1,7 +1,7 @@
package FS::cust_main::Packages;
use strict;
-use vars qw( $DEBUG $me );
+use vars qw( $DEBUG $me $skip_label_sort );
use List::Util qw( min );
use FS::UID qw( dbh );
use FS::Record qw( qsearch qsearchs );
@@ -12,6 +12,7 @@ use FS::cust_location; #
$DEBUG = 0;
$me = '[FS::cust_main::Packages]';
+$skip_label_sort = 0;
=head1 NAME
@@ -419,7 +420,9 @@ sub all_pkgs {
@cust_pkg = $self->_cust_pkg($extra_qsearch);
}
+ local($skip_label_sort) = 1 if $extra_qsearch->{skip_label_sort};
map { $_ } sort sort_packages @cust_pkg;
+
}
=item cust_pkg
@@ -467,6 +470,7 @@ sub ncancelled_pkgs {
}
+ local($skip_label_sort) = 1 if $extra_qsearch->{skip_label_sort};
sort sort_packages @cust_pkg;
}
@@ -509,7 +513,8 @@ sub sort_packages {
return 0 if !$a_num_cust_svc && !$b_num_cust_svc;
return -1 if $a_num_cust_svc && !$b_num_cust_svc;
return 1 if !$a_num_cust_svc && $b_num_cust_svc;
- return 0 if $a_num_cust_svc + $b_num_cust_svc > 20; #for perf, just give up
+ return 0 if $skip_label_sort
+ || $a_num_cust_svc + $b_num_cust_svc > 20; #for perf, just give up
my @a_cust_svc = $a->cust_svc_unsorted;
my @b_cust_svc = $b->cust_svc_unsorted;
return 0 if !scalar(@a_cust_svc) && !scalar(@b_cust_svc);
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index a4c5447..2061c2c 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -3207,16 +3207,15 @@ sub cust_svc_unsorted_arrayref {
}
my %search = (
- 'table' => 'cust_svc',
- 'hashref' => { 'pkgnum' => $self->pkgnum },
+ 'select' => 'cust_svc.*, part_svc.*',
+ 'table' => 'cust_svc',
+ 'hashref' => { 'pkgnum' => $self->pkgnum },
+ 'addl_from' => 'LEFT JOIN part_svc USING ( svcpart )',
);
- if ( $opt{svcpart} ) {
- $search{hashref}->{svcpart} = $opt{'svcpart'};
- }
- if ( $opt{'svcdb'} ) {
- $search{addl_from} = ' LEFT JOIN part_svc USING ( svcpart ) ';
- $search{extra_sql} = ' AND svcdb = '. dbh->quote( $opt{'svcdb'} );
- }
+ $search{hashref}->{svcpart} = $opt{svcpart}
+ if $opt{svcpart};
+ $search{extra_sql} = ' AND svcdb = '. dbh->quote( $opt{svcdb} )
+ if $opt{svcdb};
[ qsearch(\%search) ];
diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm
index 29298b8..7d29749 100644
--- a/FS/FS/cust_svc.pm
+++ b/FS/FS/cust_svc.pm
@@ -2,7 +2,7 @@ package FS::cust_svc;
use strict;
use vars qw( @ISA $DEBUG $me $ignore_quantity $conf $ticket_system );
-use Carp;
+use Carp qw(cluck);
#use Scalar::Util qw( blessed );
use List::Util qw( max );
use FS::Conf;
@@ -32,6 +32,15 @@ FS::UID->install_callback( sub {
$ticket_system = $conf->config('ticket_system')
});
+our $cache_enabled = 0;
+
+sub _simplecache {
+ my( $self, $hashref ) = @_;
+ if ( $cache_enabled && $hashref->{'svc'} ) {
+ $self->{'_svcpart'} = FS::part_svc->new($hashref);
+ }
+}
+
sub _cache {
my $self = shift;
my ( $hashref, $cache ) = @_;
@@ -492,9 +501,9 @@ L<FS::part_svc>).
sub part_svc {
my $self = shift;
- $self->{'_svcpart'}
- ? $self->{'_svcpart'}
- : qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
+ return $self->{_svcpart} if $self->{_svcpart};
+ cluck 'cust_svc->part_svc called' if $DEBUG;
+ qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
}
=item cust_pkg
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index 73d5647..238c64c 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -978,14 +978,11 @@ sub pkg_svc {
# qsearch( 'pkg_svc', { 'pkgpart' => $self->pkgpart } );
my $opt = ref($_[0]) ? $_[0] : { @_ };
- my %pkg_svc = map { $_->svcpart => $_ }
- grep { $_->quantity }
- qsearch( 'pkg_svc', { 'pkgpart' => $self->pkgpart } );
+ my %pkg_svc = map { $_->svcpart => $_ } $self->_pkg_svc;
unless ( $opt->{disable_linked} ) {
foreach my $dst_pkg ( map $_->dst_pkg, $self->svc_part_pkg_link ) {
- my @pkg_svc = grep { $_->quantity }
- qsearch( 'pkg_svc', { pkgpart=>$dst_pkg->pkgpart } );
+ my @pkg_svc = $dst_pkg->_pkg_svc;
foreach my $pkg_svc ( @pkg_svc ) {
if ( $pkg_svc{$pkg_svc->svcpart} ) {
my $quantity = $pkg_svc{$pkg_svc->svcpart}->quantity;
@@ -1005,6 +1002,17 @@ sub pkg_svc {
}
+sub _pkg_svc {
+ my $self = shift;
+ grep { $_->quantity }
+ qsearch({
+ 'select' => 'pkg_svc.*, part_svc.*',
+ 'table' => 'pkg_svc',
+ 'addl_from' => 'LEFT JOIN part_svc USING ( svcpart )',
+ 'hashref' => { 'pkgpart' => $self->pkgpart },
+ });
+}
+
=item svcpart [ SVCDB ]
Returns the svcpart of the primary service definition (see L<FS::part_svc>)
diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi
index 411ff16..f55083d 100755
--- a/httemplate/search/cust_main.cgi
+++ b/httemplate/search/cust_main.cgi
@@ -120,6 +120,8 @@
% my %cust_svc_by_svcpart;
% my $rows = 0;
% 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
% foreach my $part_svc (
% $cust_pkg->part_svc( summarize_size=>$large_pkg_size )
% ) {
@@ -280,12 +282,13 @@
% }
% elsif ( scalar @$these ) { # do not summarize
% foreach my $cust_svc ( @$these ) {
+% my $part_svc = $cust_svc->part_svc;
<% $n2 %>
<% $td %>
- <% FS::UI::Web::svc_link($m, $cust_svc->part_svc, $cust_svc) %>
+ <% FS::UI::Web::svc_link($m, $part_svc, $cust_svc) %>
</TD>
<% $td %>
- <% FS::UI::Web::svc_label_link($m, $cust_svc->part_svc, $cust_svc) %>
+ <% FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) %>
</TD>
% $n2="</TR><TR>";
% } #foreach $cust_svc
@@ -523,8 +526,9 @@ my $addl_from = qq{
local($FS::cust_pkg::cache_enabled) = 1; #for $cust_pkg->part_pkg
my %all_pkgs = map { $_->custnum =>
- [ $_->$pkgs_method({ select => $select,
- addl_from => $addl_from,
+ [ $_->$pkgs_method({ select => $select,
+ addl_from => $addl_from,
++ skip_label_sort => 1,
})
];
}
-----------------------------------------------------------------------
Summary of changes:
FS/FS/cust_main/Packages.pm | 9 +++++++--
FS/FS/cust_pkg.pm | 17 ++++++++---------
FS/FS/cust_svc.pm | 17 +++++++++++++----
FS/FS/part_pkg.pm | 18 +++++++++++++-----
httemplate/search/cust_main.cgi | 12 ++++++++----
5 files changed, 49 insertions(+), 24 deletions(-)
More information about the freeside-commits
mailing list