[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.7-307-ge5e4b61
Kevin Falcone
falcone at bestpractical.com
Tue Mar 30 12:13:15 EDT 2010
The branch, 3.8-trunk has been updated
via e5e4b610bb4428980c36aa7bf0ea94458c4beac5 (commit)
from 3e5afef13d314cdc29a148eed75bc7339eac3fe9 (commit)
Summary of changes:
lib/RT/Report/Tickets/Entry.pm | 26 ++++++++++++++++++++++++++
share/html/Search/Chart | 18 ++----------------
share/html/Search/Elements/Chart | 17 ++---------------
3 files changed, 30 insertions(+), 31 deletions(-)
- Log -----------------------------------------------------------------
commit e5e4b610bb4428980c36aa7bf0ea94458c4beac5
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Mon Mar 1 17:02:09 2010 -0500
Refactor this duplicated code that cleans up 1970 dates into lib
This also makes sure that we handle Hourly grouping correctly in
both pieces of code.
diff --git a/lib/RT/Report/Tickets/Entry.pm b/lib/RT/Report/Tickets/Entry.pm
index 49c1a92..4f2a8a3 100644
--- a/lib/RT/Report/Tickets/Entry.pm
+++ b/lib/RT/Report/Tickets/Entry.pm
@@ -52,6 +52,32 @@ use base qw/RT::Record/;
# XXX TODO: how the heck do we acl a report?
sub CurrentUserHasRight {1}
+=head2 LabelValue
+
+If you're pulling a value out of this collection and using it as a label,
+you may want the "cleaned up" version. This includes scrubbing 1970 dates
+and ensuring that dates are in local not DB timezones.
+
+=cut
+
+sub LabelValue {
+ my $self = shift;
+ my $field = shift;
+ my $value = $self->__Value( $field );
+
+ if ( $field =~ /(Daily|Monthly|Annually|Hourly)$/ ) {
+ my $re;
+ $re = qr{1970-01-01 00} if $field =~ /Hourly$/;
+ $re = qr{1970-01-01} if $field =~ /Daily$/;
+ $re = qr{1970-01} if $field =~ /Monthly$/;
+ $re = qr{1970} if $field =~ /Annually$/;
+ $value =~ s/^$re/Not Set/;
+ }
+
+ return $value;
+
+}
+
eval "require RT::Report::Tickets::Entry_Vendor";
if ($@ && $@ !~ qr{^Can't locate RT/Report/Tickets/Entry_Vendor.pm}) {
die $@;
diff --git a/share/html/Search/Chart b/share/html/Search/Chart
index ca33902..abee3e5 100644
--- a/share/html/Search/Chart
+++ b/share/html/Search/Chart
@@ -86,11 +86,11 @@ while ( my $entry = $tix->Next ) {
my $key;
if ( $class ) {
my $q = $class->new( $session{'CurrentUser'} );
- $q->Load( $entry->__Value( $value_name ) );
+ $q->Load( $entry->LabelValue( $value_name ) );
$key = $q->Name;
}
else {
- $key = $entry->__Value($value_name);
+ $key = $entry->LabelValue($value_name);
}
$key ||= '(no value)';
@@ -105,20 +105,6 @@ while ( my $entry = $tix->Next ) {
$max_key_length = length $key if $max_key_length < length $key;
}
-# XXX: Convert 1970-01-01 date to the 'Not Set'
-# this code should be generalized!!!
-if ( $PrimaryGroupBy =~ /(Daily|Monthly|Annually)$/ ) {
- my $re;
- $re = qr{1970-01-01} if $PrimaryGroupBy =~ /Daily$/;
- $re = qr{1970-01} if $PrimaryGroupBy =~ /Monthly$/;
- $re = qr{1970} if $PrimaryGroupBy =~ /Annually$/;
- foreach my $k (keys %data) {
- my $tmp = $k;
- $tmp =~ s/^$re/loc('Not Set')/e or next;
- $data{$tmp} = delete $data{$k};
- }
-}
-
unless (keys %data) {
$data{''} = 0;
}
diff --git a/share/html/Search/Elements/Chart b/share/html/Search/Elements/Chart
index 593d1b7..4355006 100644
--- a/share/html/Search/Elements/Chart
+++ b/share/html/Search/Elements/Chart
@@ -72,29 +72,16 @@ my (@keys, @values);
while ( my $entry = $tix->Next ) {
if ($class) {
my $q = $class->new( $session{'CurrentUser'} );
- $q->Load( $entry->__Value( $value_name ) );
+ $q->Load( $entry->LabelValue( $value_name ) );
push @keys, $q->Name;
}
else {
- push @keys, $entry->__Value( $value_name );
+ push @keys, $entry->LabelValue( $value_name );
}
$keys[-1] ||= loc('(no value)');
push @values, $entry->__Value( $count_name );
}
-# XXX: Convert 1970-01-01 date to the 'Not Set'
-# this code should be generalized!!!
-if ( $PrimaryGroupBy =~ /(Hourly|Daily|Monthly|Annually)$/ ) {
- my $re;
- $re = qr{1970-01-01 00} if $PrimaryGroupBy =~ /Hourly$/;
- $re = qr{1970-01-01} if $PrimaryGroupBy =~ /Daily$/;
- $re = qr{1970-01} if $PrimaryGroupBy =~ /Monthly$/;
- $re = qr{1970} if $PrimaryGroupBy =~ /Annually$/;
- foreach (@keys) {
- s/^$re/loc('Not Set')/e;
- }
-}
-
my %data;
my %loc_keys;
foreach my $key (@keys) { $data{$key} = shift @values; $loc_keys{$key} = loc($key); }
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list