[Rt-commit] rt branch, 4.6/custom-date-ranges, repushed

? sunnavy sunnavy at bestpractical.com
Wed Jun 12 15:41:14 EDT 2019


The branch 4.6/custom-date-ranges was deleted and repushed:
       was eaa2317268338d950e6b39658bc3ff64f0dd3374
       now 990fe87b261bd17a264c84500ac8024c8b4aa382

 1: 5aa3aa9a2 !  1: d19d1432f RT::Record support for CustomDateRanges
    @@ -11,17 +11,22 @@
      
     +# Matches one field in "field - field" style range specs. Subclasses
     +# that can participate in custom date ranges should override this method
    -+# to match their additional date fields (e.g. RT::Ticket adds "due").
    -+# Be sure to call this superclass method to get "now" and CF parsing.
    ++# to match their additional date fields. Be sure to call this superclass
    ++# method to get "now", datetime columns and CF parsing.
     +
     +sub _CustomDateRangeFieldParser {
     +    my $self = shift;
    -+    return qr{
    ++    my $regex = qr{
     +        now
    -+        | created
    -+        | last \ ? updated
     +        | cf\. (?: \{ .*? \} | \S+ )
     +    }xi;
    ++
    ++    for my $column ( keys %{ $_TABLE_ATTR->{ ref $self || $self} } ) {
    ++        my $entry = $_TABLE_ATTR->{ ref $self || $self}{$column};
    ++        next unless $entry->{read} && ( $entry->{type} // '' ) eq 'datetime';
    ++        $regex .= '|' . qr{$column}i;
    ++    }
    ++    return $regex;
     +}
     +
     +# Returns an RT::Date instantiated with this record's value for the parsed
    @@ -39,12 +44,6 @@
     +    if (lc($field) eq 'now') {
     +        $date->Set(Format => 'unix', Value => time);
     +    }
    -+    elsif (lc($field) eq 'created') {
    -+        $date = $self->CreatedObj;
    -+    }
    -+    elsif ($field =~ /^last ?updated$/i) {
    -+        $date = $self->LastUpdatedObj;
    -+    }
     +    elsif ($field =~ m{^ cf\. (?: \{ (.*?) \} | (\S+) ) $}xi) {
     +        my $name = $1 || $2;
     +        my $value = $self->FirstCustomFieldValue($name);
    @@ -57,8 +56,20 @@
     +        $date->Set(Format => 'unknown', Value => $value, Timezone => 'UTC');
     +    }
     +    else {
    -+        RT->Logger->error("Unable to parse '$field' as a field name in CustomDateRanges '$range_name'");
    -+        return;
    ++        if ( my ($column) = grep { lc $field eq lc $_ } keys %{ $_TABLE_ATTR->{ ref $self || $self } } ) {
    ++            my $method = $column . 'Obj';
    ++            if ( $self->can($method) ) {
    ++                $date = $self->$method;
    ++            }
    ++            else {
    ++                RT->Logger->error( "Missing $method in " . ref $self );
    ++                return;
    ++            }
    ++        }
    ++        else {
    ++            RT->Logger->error("Unable to parse '$field' as a field name in CustomDateRanges '$range_name'");
    ++            return;
    ++        }
     +    }
     +
     +    return $date;
 2: 731eed308 < --:  ------- RT::Ticket support for CustomDateRanges
--:  ------- >  2: a9107a774 Add "LastContact" alias for CustomDateRanges
 3: 265a267d2 =  3: 8c804c361 Add RT::Ticket CustomDateRanges to query builder
 4: d0b9d4253 =  4: 1875c8b79 Add Asset ColumnMap entries for CustomDateRanges
 5: 508b677b3 =  5: 1082523c6 Add config validation for CustomDateRanges
 6: 82cb6ee88 =  6: 74ab48f4e RT_Config doc for CustomDateRanges
 7: a83746824 =  7: d5c930eaf Switch customization doc from date range to message count
 8: 3389a9012 !  8: fdc9b920a Add tests for CustomDateRanges
    @@ -45,7 +45,7 @@
     +    'Due - Resolved' => '4 days',
     +    'Due - Told' => undef, # told is unset
     +    'now - LastContact' => undef, # told is unset
    -+    'now - Last Updated' => '0 seconds',
    ++    'now - LastUpdated' => '0 seconds',
     +    'Due - CF.{Beta Date}' => '6 days',
     +    'now - CF.{Beta Date}' => '3 weeks',
     +    'CF.{Beta Date} - now' => '3 weeks prior',
 9: 328231f3c =  9: 6a4d91832 Add business time support for custom date range
10: eaa231726 = 10: 990fe87b2 Test business time for custom date range



More information about the rt-commit mailing list