[Rt-commit] rt branch, 4.4/custom-date-ranges, repushed
Shawn Moore
shawn at bestpractical.com
Wed Aug 10 12:37:02 EDT 2016
The branch 4.4/custom-date-ranges was deleted and repushed:
was 5102da8c223ff179701b433bd220b5c371497693
now b5a67669da0326bea63b36d1841786667a624539
1: 693732d ! 1: a748c47 RT::Record support for CustomDateRanges
@@ -35,9 +35,16 @@
+ if (lc($field) eq 'now') {
+ $date->Set(Format => 'unix', Value => time);
+ }
-+ elsif ($field =~ /^CF\.(?:\{(.*)\}|(.*))$/) {
++ elsif ($field =~ m{^ cf\. (?: \{ (.*?) \} | (\S+) ) $}xi) {
+ my $name = $1 || $2;
-+ $date->Set(Format => 'sql', Value => $self->FirstCustomFieldValue($name));
++ my $value = $self->FirstCustomFieldValue($name);
++
++ if (!$value) {
++ # no CF value for this record, so bail out
++ return;
++ }
++
++ $date->Set(Format => 'unknown', Value => $value);
+ }
+ else {
+ RT->Logger->error("Unable to parse '$field' as a field name in CustomDateRanges '$range_name'");
2: cb396d3 ! 2: 620ea2a RT::Ticket support for CustomDateRanges
@@ -12,13 +12,14 @@
-1;
+sub _DateForCustomDateRangeField {
+ my $self = shift;
-+ my $field = shift;
++ my $orig = shift;
++ my $field = lc($orig);
+
-+ if (lc($field) eq 'created') { return $self->CreatedObj }
-+ elsif (lc($field) eq 'starts') { return $self->StartsObj }
-+ elsif (lc($field) eq 'started') { return $self->StartedObj }
-+ elsif (lc($field) eq 'due') { return $self->DueObj }
-+ elsif (lc($field) eq 'resolved') { return $self->ResolvedObj }
++ if ($field eq 'created') { return $self->CreatedObj }
++ elsif ($field eq 'starts') { return $self->StartsObj }
++ elsif ($field eq 'started') { return $self->StartedObj }
++ elsif ($field eq 'due') { return $self->DueObj }
++ elsif ($field eq 'resolved') { return $self->ResolvedObj }
+ elsif ($field =~ /^(?:told|last ?contact)$/i) {
+ return $self->ToldObj;
+ }
@@ -26,7 +27,7 @@
+ return $self->LastUpdatedObj;
+ }
+ else {
-+ return $self->SUPER::_DateForCustomDateRangeField($field, @_);
++ return $self->SUPER::_DateForCustomDateRangeField($orig, @_);
+ }
+}
+
3: 76cfd9a = 3: 31d7017 RT::Asset support for CustomDateRanges
4: b8ff871 ! 4: 8aa6781 Add RT::Ticket CustomDateRanges to query builder
@@ -10,14 +10,16 @@
},
};
+
-+my %ranges = %{ RT->Config->Get('CustomDateRanges')->{'RT::Ticket'} || {} };
-+for my $name (keys %ranges) {
-+ $COLUMN_MAP->{$name} = {
-+ title => $name,
-+ value => sub {
-+ $_[0]->CustomDateRange($name, $ranges{$name});
-+ },
-+ };
++if (RT->Config->Get('CustomDateRanges')) {
++ my %ranges = %{ RT->Config->Get('CustomDateRanges')->{'RT::Ticket'} || {} };
++ for my $name (keys %ranges) {
++ $COLUMN_MAP->{$name} = {
++ title => $name,
++ value => sub {
++ $_[0]->CustomDateRange($name, $ranges{$name});
++ },
++ };
++ }
+}
</%ONCE>
<%init>
@@ -30,8 +32,10 @@
push @fields, "CustomRole.{" . $Role->Name . "}";
}
-+my %ranges = %{ RT->Config->Get('CustomDateRanges')->{'RT::Ticket'} || {} };
-+push @fields, sort keys %ranges;
++if (RT->Config->Get('CustomDateRanges')) {
++ my %ranges = %{ RT->Config->Get('CustomDateRanges')->{'RT::Ticket'} || {} };
++ push @fields, sort keys %ranges;
++}
+
$m->callback( Fields => \@fields, ARGSRef => \%ARGS );
5: 6a09f78 = 5: b1f9be4 Add config validation for CustomDateRanges
6: 601fb03 ! 6: 056f77d RT_Config doc for CustomDateRanges
@@ -20,11 +20,11 @@
+
+ Set(%CustomDateRanges,
+ 'RT::Ticket' => {
-+ 'Containment' => 'Resolved - Created',
++ 'Resolution Time' => 'Resolved - Created',
+
+ 'Downtime' => 'CF.{First Alert} - CF.Recovered',
+
-+ 'Time Til Beta' => {
++ 'Time To Beta' => {
+ value => 'CF.Beta - now',
+
+ format => sub {
@@ -76,8 +76,8 @@
+
+=back
+
-+Operations besides subtraction are unsupported. There must be whitespace
-+between each field and the C<-> substraction operator.
++Custom date range calculations are defined using typical math operators with
++a space before and after. Subtraction (-) is currently supported.
+
+If either field is unset, nothing will be displayed for that record (and the
+C<format> code reference will not be called). If you need additional control
7: 8af1bda = 7: c4b8db0 Switch customization doc from date range to message count
8: 9dc1b28 = 8: 341cf0f Remove "# loc" and description from example
9: 06f9163 = 9: 06d9f15 Add tests for CustomDateRanges
10: 5102da8 = 10: b5a6766 Add Asset ColumnMap entries for CustomDateRanges
More information about the rt-commit
mailing list