optimization for ginourmous numbers of packages for intergate, whew
authorivan <ivan>
Tue, 24 Dec 2002 22:41:23 +0000 (22:41 +0000)
committerivan <ivan>
Tue, 24 Dec 2002 22:41:23 +0000 (22:41 +0000)
FS/bin/freeside-setup
README.1.5.0pre1
httemplate/view/cust_main.cgi

index 8f3d99f..8b74662 100755 (executable)
@@ -669,7 +669,7 @@ sub tables_hash_hack {
       ],
       'primary_key' => 'pkgpart',
       'unique' => [],
-      'index' => [],
+      'index' => [ [ disabled ], ],
     },
 
 #    'part_title' => {
@@ -712,7 +712,7 @@ sub tables_hash_hack {
       ],
       'primary_key' => 'svcpart',
       'unique' => [],
-      'index' => [],
+      'index' => [ [ 'disabled' ] ],
     },
 
     'part_svc_column' => {
index 57fc36a..0de86bc 100644 (file)
@@ -7,6 +7,7 @@ schema changes:
   *** add column cust_main_county.taxname
   *** add column cust_bill_pkg.itemdesc
   *** drop index cust_bill_pkg1
+  *** add index part_pkg1 and part_svc1
 
 install DBIx::DBSchema 0.21
 install NetAddr::IP
index 62e961d..6fe759b 100755 (executable)
@@ -280,14 +280,14 @@ print '<BR>'.
   qq!<INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!.
   '<SELECT NAME="pkgpart"><OPTION> ';
 
-foreach my $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) {
-  my $pkgpart = $type_pkgs->pkgpart;
-#  my $part_pkg = qsearchs('part_pkg', { 'pkgpart' => $pkgpart } )
-#    or do { warn "unknown type_pkgs.pkgpart $pkgpart"; next; };
-  my $part_pkg =
-    qsearchs('part_pkg', { 'pkgpart' => $pkgpart, 'disabled' => '' } )
-    or next;
-  print qq!<OPTION VALUE="$pkgpart">!. $part_pkg->pkg. ' - '.
+foreach my $part_pkg (
+  qsearch( 'part_pkg', { 'disabled' => '' }, '',
+           ' AND 0 < ( SELECT COUNT(*) FROM type_pkgs '.
+           '             WHERE typenum = '. $agent->typenum.
+           '             AND type_pkgs.pkgpart = part_pkg.pkgpart )'
+         )
+) {
+  print '<OPTION VALUE="'. $part_pkg->pkgpart. '">'. $part_pkg->pkg. ' - '.
         $part_pkg->comment;
 }