[freeside-devel] [PATCH] avoid qsearch for pkg_svc call in pkg
edit
ivan
ivan at 420.am
Tue Jul 12 02:22:32 PDT 2005
applied, thanks! mmm refactoring :)
On Mon, Jun 13, 2005 at 03:21:06PM -0400, Ricardo SIGNES wrote:
> This patch is part of my continuing effort to avoid using SQL and
> qsearch from templates to find the pkg_svc records for a package.
>
> --
> rjbs
> Index: httemplate/edit/part_pkg.cgi
> ===================================================================
> RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/part_pkg.cgi,v
> retrieving revision 1.54
> diff -u -r1.54 part_pkg.cgi
> --- httemplate/edit/part_pkg.cgi 1 Jun 2005 02:39:16 -0000 1.54
> +++ httemplate/edit/part_pkg.cgi 13 Jun 2005 19:19:09 -0000
> @@ -187,22 +187,20 @@
> )";
> }
> my @part_svc = qsearch('part_svc', {}, '', $where);
> +my %pkg_svc = map { $_->svcpart => $_ } $part_pkg->pkg_svc;
>
> my @fixups = ();
> my $count = 0;
> my $columns = 3;
> foreach my $part_svc ( @part_svc ) {
> my $svcpart = $part_svc->svcpart;
> - my $pkg_svc = $pkgpart && qsearchs( 'pkg_svc', {
> - 'pkgpart' => $pkgpart,
> - 'svcpart' => $svcpart,
> - } ) || new FS::pkg_svc ( {
> - 'pkgpart' => $pkgpart,
> - 'svcpart' => $svcpart,
> - 'quantity' => 0,
> - 'primary_svc' => '',
> - });
> - #? #next unless $pkg_svc;
> + my $pkg_svc = $pkg_svc{$svcpart}
> + || new FS::pkg_svc ( {
> + 'pkgpart' => $pkgpart,
> + 'svcpart' => $svcpart,
> + 'quantity' => 0,
> + 'primary_svc' => '',
> + } );
>
> push @fixups, "pkg_svc$svcpart";
>
--
_ivan
More information about the freeside-devel
mailing list