[freeside-commits] freeside/FS/FS agent_type.pm,1.4,1.5

Ivan,,, ivan at wavetail.420.am
Wed Jun 21 01:42:20 PDT 2006


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv25961/FS/FS

Modified Files:
	agent_type.pm 
Log Message:
speed up the agent type report when there are lots of package definitions

Index: agent_type.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/agent_type.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- agent_type.pm	14 May 2006 16:47:31 -0000	1.4
+++ agent_type.pm	21 Jun 2006 08:42:18 -0000	1.5
@@ -136,6 +136,27 @@
   qsearch('type_pkgs', { 'typenum' => $self->typenum } );
 }
 
+=item type_pkgs_enabled
+
+Returns all FS::type_pkg objects (see L<FS::type_pkgs>) that link to enabled
+package definitions (see L<FS::part_pkg>).
+
+An additional strange feature is that the returned type_pkg objects also have
+all fields of the associated part_pkg object.
+
+=cut
+
+sub type_pkgs_enabled {
+  my $self = shift;
+  qsearch({
+    'table'     => 'type_pkgs',
+    'addl_from' => 'JOIN part_pkg USING ( pkgpart )',
+    'hashref'   => { 'typenum' => $self->typenum },
+    'extra_sql' => " AND ( disabled = '' OR disabled IS NULL )".
+                   " ORDER BY pkg",
+  });
+}
+
 =item pkgpart
 
 Returns the pkgpart of all package definitions (see L<FS::part_pkg>) for this
@@ -152,6 +173,13 @@
 
 =head1 BUGS
 
+type_pkgs_enabled should order itself by something (pkg?)
+
+type_pkgs_enabled should populate something that caches for the part_pkg method
+rather than add fields to this object, right?  In fact we need a "poop" object
+framework that does that automatically for any joined search at some point....
+right?
+
 =head1 SEE ALSO
 
 L<FS::Record>, L<FS::agent>, L<FS::type_pkgs>, L<FS::cust_main>,



More information about the freeside-commits mailing list