[Rt-commit] rt branch, 4.2-trunk, updated. rt-4.2.11-34-g1b636e5
Shawn Moore
shawn at bestpractical.com
Mon Jun 29 17:10:34 EDT 2015
The branch, 4.2-trunk has been updated
via 1b636e5536904ded6ab2668ab215bdb6a38bc407 (commit)
from 692227c0278082082fe267160aed688b0907307e (commit)
Summary of changes:
lib/RT/Report/Tickets.pm | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
- Log -----------------------------------------------------------------
commit 1b636e5536904ded6ab2668ab215bdb6a38bc407
Author: Christian Loos <cloos at netcologne.de>
Date: Fri Jun 19 13:16:04 2015 +0200
Sort charts numerically when possible
83f09730 fixed sorting for numeric CF labels. This extends that to check all
labels for numeric values and sorts them accordingly. This fixes sorting of
time values like Hour, Day or WeekOfYear.
diff --git a/lib/RT/Report/Tickets.pm b/lib/RT/Report/Tickets.pm
index 19bca18..a535111 100644
--- a/lib/RT/Report/Tickets.pm
+++ b/lib/RT/Report/Tickets.pm
@@ -673,27 +673,24 @@ sub SortEntries {
for ( my $i = 0; $i < @groups; $i++ ) {
my $group_by = $groups[$i];
my $idx = $i+1;
- my $method;
- # If this is a CF, traverse the values being used for labels.
- # If they all look like numbers or undef, flag for a numeric sort
-
- my $looks_like_number;
- if ( $group_by->{'KEY'} eq 'CF' ){
- $looks_like_number = 1;
+ my $order = $group_by->{'META'}{Sort} || 'label';
+ my $method = $order =~ /label$/ ? 'LabelValue' : 'RawValue';
+ unless ($order =~ /^numeric/) {
+ # Traverse the values being used for labels.
+ # If they all look like numbers or undef, flag for a numeric sort.
+ my $looks_like_number = 1;
foreach my $item (@data){
- my $cf_label = $item->[0]->RawValue($group_by->{'NAME'});
+ my $label = $item->[0]->$method($group_by->{'NAME'});
$looks_like_number = 0
- unless (not defined $cf_label)
- or Scalar::Util::looks_like_number( $cf_label );
+ unless (not defined $label)
+ or Scalar::Util::looks_like_number( $label );
}
+ $order = "numeric $order" if $looks_like_number;
}
- my $order = $looks_like_number ? 'numeric label' : 'label';
- $order = $group_by->{'META'}{Sort} if exists $group_by->{'META'}{Sort};
-
if ( $order eq 'label' ) {
push @SORT_OPS, sub { $_[0][$idx] cmp $_[1][$idx] };
$method = 'LabelValue';
-----------------------------------------------------------------------
More information about the rt-commit
mailing list