[Rt-commit] rt branch, topic/chart-labels, created. rt-3.8.7-177-g65acc01
Kevin Falcone
falcone at bestpractical.com
Mon Mar 1 17:26:55 EST 2010
The branch, topic/chart-labels has been created
at 65acc01bfd1fae6fd9252b34892cb35a9f976879 (commit)
- Log -----------------------------------------------------------------
commit f2d1f5fc9977b36b3ab6b5c31478f32fb131dc44
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
diff --git a/lib/RT/Report/Tickets/Entry.pm b/lib/RT/Report/Tickets/Entry.pm
index 49c1a92..5dab270 100644
--- a/lib/RT/Report/Tickets/Entry.pm
+++ b/lib/RT/Report/Tickets/Entry.pm
@@ -52,6 +52,31 @@ 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)$/ ) {
+ my $re;
+ $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 59e9fc6..448291b 100644
--- a/share/html/Search/Chart
+++ b/share/html/Search/Chart
@@ -125,11 +125,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)';
@@ -142,20 +142,6 @@ while ( my $entry = $tix->Next ) {
$data{ $key } = $value;
}
-# 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 3db92c4..c547f35 100644
--- a/share/html/Search/Elements/Chart
+++ b/share/html/Search/Elements/Chart
@@ -72,28 +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 =~ /(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 (@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); }
commit e26f5add51c6c71227a5680057048bb62ef0ae63
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Mon Mar 1 17:04:04 2010 -0500
Handle Not Set dates when grouping hourly
diff --git a/lib/RT/Report/Tickets/Entry.pm b/lib/RT/Report/Tickets/Entry.pm
index 5dab270..4f2a8a3 100644
--- a/lib/RT/Report/Tickets/Entry.pm
+++ b/lib/RT/Report/Tickets/Entry.pm
@@ -65,8 +65,9 @@ sub LabelValue {
my $field = shift;
my $value = $self->__Value( $field );
- if ( $field =~ /(Daily|Monthly|Annually)$/ ) {
+ 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$/;
commit 65acc01bfd1fae6fd9252b34892cb35a9f976879
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Mon Mar 1 17:24:13 2010 -0500
Redo chart labels to be in the right timezone
Do a little date munging so that rather than showing the GMT hours
when grouping by CreatedHourly, we convert those to the local tz.
diff --git a/lib/RT/Report/Tickets/Entry.pm b/lib/RT/Report/Tickets/Entry.pm
index 4f2a8a3..1566dde 100644
--- a/lib/RT/Report/Tickets/Entry.pm
+++ b/lib/RT/Report/Tickets/Entry.pm
@@ -74,6 +74,13 @@ sub LabelValue {
$value =~ s/^$re/Not Set/;
}
+ if ( $field =~ /Hourly$/ && $value ne 'Not Set' ) {
+ $value .= ":00:00";
+ my $date = RT::Date->new($self->CurrentUser);
+ $date->Set(Value => $value, Format => 'ISO', Timezone => 'UTC' );
+ $value = $date->ISO( Timezone => 'User', Seconds => 0 );
+ }
+
return $value;
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list