summaryrefslogtreecommitdiff
path: root/httemplate/graph
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2014-01-13 15:52:50 -0800
committerMark Wells <mark@freeside.biz>2014-01-13 15:52:50 -0800
commitfadbf7963db877d3c37028805cbb656ba1d634ec (patch)
tree4c5ead5ebccf67a3ee3bfc9bc4a553e657d2bcfe /httemplate/graph
parentdd0bf7c0db2d97a33bedd324788ca550b54572fc (diff)
query optimization for #25459
Diffstat (limited to 'httemplate/graph')
-rw-r--r--httemplate/graph/cust_bill_pkg.cgi34
1 files changed, 18 insertions, 16 deletions
diff --git a/httemplate/graph/cust_bill_pkg.cgi b/httemplate/graph/cust_bill_pkg.cgi
index 1b31955c4..44498c85e 100644
--- a/httemplate/graph/cust_bill_pkg.cgi
+++ b/httemplate/graph/cust_bill_pkg.cgi
@@ -103,7 +103,7 @@ if ( $cgi->param('class_mode') eq 'report' ) {
$value_col = 'classnum';
}
-my @classnums = grep /^\d+$/, $cgi->param($class_param);
+my @classnums = sort {$a <=> $b} grep /^\d+$/, $cgi->param($class_param);
my @classnames = map { if ( $_ ) {
my $class = qsearchs($class_table, {$value_col=>$_} );
$class->$name_col;
@@ -128,22 +128,24 @@ if ( $cgi->param('class_agg_break') eq 'aggregate' or
if ( $cgi->param('class_mode') eq 'report' ) {
# The new way:
# Actually break down all subsets of the (selected) report classes.
- my $powerset = sub {
- my @set = [];
- foreach my $x (@_) {
- @set = map { $_, [ @$_, $x ] } @set;
+ my @subsets = FS::part_pkg_report_option->subsets(@classnums);
+ warn "SUBSETS:\n".Dumper(\@subsets)."\n\n";
+ my @classnum_space = @classnums;
+ @classnums = @classnames = ();
+ while(@subsets) {
+ my $these = shift @subsets;
+ # applied topology!
+ my $not_these = [ @classnum_space ];
+ my $i = 0;
+ foreach (@$these) {
+ $i++ until $not_these->[$i] == $_;
+ splice($not_these, $i, 1);
}
- @set;
- };
- @classnums = $powerset->(@classnums);
- @classnames = $powerset->(@classnames);
- # this is pairwise complementary to @classnums, because math
- @not_classnums = reverse(@classnums);
-warn Dumper(\@classnums, \@classnames, \@not_classnums);
- # remove the null set
- shift @classnums;
- shift @classnames;
- shift @not_classnums;
+ push @classnums, $these;
+ push @not_classnums, $not_these;
+ push @classnames, shift @subsets;
+ } #while subsets
+ warn "COMPLEMENTS:\n".Dumper(\@not_classnums)."\n\n";
}
# else it's 'pkg', i.e. part_pkg.classnum, which is singular on pkgpart
# and much simpler