Am 24.03.2010 14:43, schrieb Jesper Henriksen:
> Hey all,
> 
> Is there a way to get reports on how much time a ticket has been open?
> For example we would like to see the average time it takes from when a
> customer reports a problem till we have closed the ticket. Bear in mind
> that if the ticket is closed and then re-opened, the duration in which
> it was closed should not be counted.
> 
> It would also be nice if we could see how much time has passed from when
> the requestor (customer) creates or updates a ticket till one of our
> support members responds to it.
> 
> I've searched the list and google in every way I could imagine, but I
> just can't crack this nut. Can anyone help? I'm trying to setup RT for
> my new employer and these report features are critical to us.
> 

Hi Jesper,

you can do this with an callback under
local/html/Callbacks/MyCallback/Elements/RT__Ticket/ColumnMap/Once
where you extend the ticket column_map.
Attached is the callback I use, where I compare created to resolved in days.
You can then add the new field 'DaysCreatedToResolved' to the ticket
search result.

If you also want to use it within the chart feature it is a little more
difficult. You have to copy lib/RT/Report/Tickets.pm to
local/lib/RT/Report/Tickets.pm and modify it.
Attached an diff of my version BUT this only works for mysql. I also
removed some lines from the diff because I have some other modifications
in this file, so don't apply the diff, use it as an example. One
limitation that I didn't fixed is, that the days (DaysCreatedToResolved)
are not sorted in the chart.

If anyone else have done something similar, I would appreciate feedback.

Chris

<%ARGS>
$COLUMN_MAP => {}
</%ARGS>
<%INIT>
$COLUMN_MAP->{DaysCreatedToResolved} = {
    title => 'DaysCreatedToResolved',
    value => sub {
        my $Created  = $_[0]->CreatedObj->SetToMidnight;
        my $Resolved = $_[0]->ResolvedObj->SetToMidnight;
        return '' unless ( $Resolved > 0 );
        return '< 1' if ( $Resolved == $Created );
        return ($Resolved-$Created)/60/60/24;
    }
}
</%INIT>
--- /opt/rt3/lib/RT/Report/Tickets.pm   2009-11-18 10:49:45.000000000 +0100
+++ /opt/rt3/local/lib/RT/Report/Tickets.pm     2010-02-26 13:26:13.000000000 
+0100
@@ -69,12 +69,13 @@
     }
 
     push @fields, map {$_, $_} qw(
+        DaysCreatedToResolved
     );
 
     my $queues = $args{'Queues'};
@@ -229,6 +233,9 @@
             $self->{"_sql_report_watcher_users_alias_$type"} = $u_alias;
         }
         @args{qw(ALIAS FIELD)} = ($u_alias, $column);
+    } elsif ( $field =~ /DaysCreatedToResolved/ ) {
+        my $alias = $args{'ALIAS'} || 'main';
+        $args{'FUNCTION'} = "IF(DATEDIFF($alias.Resolved, $alias.Created) = 0, 
'< 1', IF($alias.Resolved > $alias.Created, DATEDIFF($alias.Resolved, 
$alias.Created), NULL))";
     }
     return %args;
 }
Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Reply via email to