From 6c472b9d7eb5d64026baf188623cc133416253f6 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 21 Jun 2006 08:42:18 +0000 Subject: [PATCH] speed up the agent type report when there are lots of package definitions --- FS/FS/agent_type.pm | 28 ++++++++++++++++++++++++++++ httemplate/browse/agent_type.cgi | 13 +++++-------- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/FS/FS/agent_type.pm b/FS/FS/agent_type.pm index b28c57285..2660bb4a3 100644 --- a/FS/FS/agent_type.pm +++ b/FS/FS/agent_type.pm @@ -136,6 +136,27 @@ sub type_pkgs { qsearch('type_pkgs', { 'typenum' => $self->typenum } ); } +=item type_pkgs_enabled + +Returns all FS::type_pkg objects (see L) that link to enabled +package definitions (see L). + +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) for this @@ -152,6 +173,13 @@ sub pkgpart { =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, L, L, L, diff --git a/httemplate/browse/agent_type.cgi b/httemplate/browse/agent_type.cgi index a5ffb1048..ceffce3d4 100755 --- a/httemplate/browse/agent_type.cgi +++ b/httemplate/browse/agent_type.cgi @@ -13,21 +13,18 @@ my $packages_sub = sub { [ map { my $type_pkgs = $_; - my $part_pkg = $type_pkgs->part_pkg; + #my $part_pkg = $type_pkgs->part_pkg; [ { - 'data' => $part_pkg->pkg. ' - '. $part_pkg->comment, + #'data' => $part_pkg->pkg. ' - '. $part_pkg->comment, + 'data' => $type_pkgs->pkg. ' - '. $type_pkgs->comment, 'align' => 'left', 'link' => $p. 'edit/part_pkg.cgi?'. $type_pkgs->pkgpart, }, ]; } - #sort { - # } - grep { - $_->part_pkg and ! $_->part_pkg->disabled - } - $agent_type->type_pkgs #XXX the method should order itself by something + + $agent_type->type_pkgs_enabled ]; }; -- 2.11.0