[PATCH] avoid qsearch for pkg_svc call in pkg edit
Ricardo SIGNES
rjbs+freeside-devel at icgroup.com
Mon Jun 13 12:20:54 PDT 2005
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
-------------- next part --------------
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";
More information about the freeside-devel
mailing list