[freeside-commits] freeside/FS/FS cust_main.pm,1.412,1.413
Ivan,,,
ivan at wavetail.420.am
Sun Mar 29 18:05:06 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv14746/FS/FS
Modified Files:
cust_main.pm
Log Message:
forget caching, instead scoop up cust_pkg and part_pkg in one query, RT#5083
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.412
retrieving revision 1.413
diff -u -d -r1.412 -r1.413
--- cust_main.pm 26 Mar 2009 03:53:45 -0000 1.412
+++ cust_main.pm 30 Mar 2009 01:05:04 -0000 1.413
@@ -1809,7 +1809,7 @@
scalar( grep { $self->getfield("ship_$_") ne '' } $self->addr_fields );
}
-=item all_pkgs
+=item all_pkgs [ EXTRA_QSEARCH_PARAMS_HASHREF ]
Returns all packages (see L<FS::cust_pkg>) for this customer.
@@ -1817,14 +1817,19 @@
sub all_pkgs {
my $self = shift;
+ my $extra_qsearch = ref($_[0]) ? shift : {};
- return $self->num_pkgs unless wantarray;
+ return $self->num_pkgs unless wantarray; #XXX doesn't work w/$extra_qsearch
my @cust_pkg = ();
if ( $self->{'_pkgnum'} ) {
@cust_pkg = values %{ $self->{'_pkgnum'}->cache };
} else {
- @cust_pkg = qsearch( 'cust_pkg', { 'custnum' => $self->custnum });
+ @cust_pkg = qsearch({
+ %$extra_qsearch,
+ 'table' => 'cust_pkg',
+ 'hashref' => { 'custnum' => $self->custnum },
+ });
}
sort sort_packages @cust_pkg;
@@ -1851,7 +1856,7 @@
qsearch('cust_location', { 'custnum' => $self->custnum } );
}
-=item ncancelled_pkgs
+=item ncancelled_pkgs [ EXTRA_QSEARCH_PARAMS_HASHREF ]
Returns all non-cancelled packages (see L<FS::cust_pkg>) for this customer.
@@ -1859,6 +1864,7 @@
sub ncancelled_pkgs {
my $self = shift;
+ my $extra_qsearch = ref($_[0]) ? shift : {};
return $self->num_ncancelled_pkgs unless wantarray;
@@ -1877,16 +1883,13 @@
$self->custnum. "\n"
if $DEBUG > 1;
- @cust_pkg =
- qsearch( 'cust_pkg', {
- 'custnum' => $self->custnum,
- 'cancel' => '',
- });
- push @cust_pkg,
- qsearch( 'cust_pkg', {
- 'custnum' => $self->custnum,
- 'cancel' => 0,
- });
+ @cust_pkg = qsearch({
+ %$extra_qsearch,
+ 'table' => 'cust_pkg',
+ 'hashref' => { 'custnum' => $self->custnum },
+ 'extra_sql' => ' AND ( cancel IS NULL OR cancel = 0 ) ',
+ });
+
}
sort sort_packages @cust_pkg;
More information about the freeside-commits
mailing list