<& /Elements/Header, Title => 'RT Statistics: Average Time To Resolution' &> <& /Statistics/Elements/Tabs, Title => "RT Statistics: Average Time To Resolution" &>

Times for <% $QueueObj->Name || "All Queues" %>

% for my $d (0..$#dates) { % my $x = 1; % my $tix = new RT::Tickets($session{'CurrentUser'}); % $tix->LimitCreated(VALUE => $dates[$d]->ISO, OPERATOR => ">="); % if ($dates[$d+1]) { % $tix->LimitCreated(VALUE => $dates[$d+1]->ISO, OPERATOR => "<="); % } % if ($queue) { % $tix->LimitQueue (VALUE => $queue); % } % $tix->LimitStatus(VALUE => "resolved"); %}
Dates Tickets Created On This Day Resolved Time to Resolution
<% Statistics::FormatDate($dateformat, $dates[$d]) %> <% $tix->Count %> <% $tix->Count %> % if ($tix->Count) { % my @tix = @{$tix->ItemsArrayRef}; % my $total; % $total += ($_->ResolvedObj->Unix - $_->CreatedObj->Unix) for @tix; % my $average = int ($total / @tix); <& /Statistics/Elements/DurationAsString, Duration => $average &> % $data[$x++][$d] = $average; % } else { N/A % }
See Queue:
<& /Elements/SelectQueue, Name=>"queue", ShowNullOption=>1 &>
Days to see: See weekends: name="weekends">


<%perl> my $url = 'Elements/Chart?x_labels='; #$url .= join ",", @{ shift @data }; for(0..$max) { $url .= $data[0][$_] . ","; } chop $url; $url .= '&'; shift @data; #$url .= 'y_number_format=&'; # does not work if no ticket has been resolved as of today... # sometimes not all resolved tickets are found )-: for (0..$#data) { $url .= "data".(1+$_)."=".(join ",", @{$data[$_]})."&"; } chop $url;
<%ARGS> $max => $Statistics::TimeToResolveMaxRows $queue => $Statistics::TimeToResolveQueue $weekends => $Statistics::TimeToResolveWeekends $dateformat => $Statistics::TimeToResolveDateFormat <%INIT> use Statistics; my $n = 0; my @data = ([]); my @dates; my @msgs; $max--; my $QueueObj = new RT::Queue($session{'CurrentUser'}); $QueueObj->Load($queue); until ($#dates == $max) { my $date = new RT::Date($session{CurrentUser}); $date->Set(Value=>time - $n, Format => 'unix'); Statistics::RTDateSetToLocalMidnight($date); $n+= 60*60*24; next if !$weekends and Statistics::RTDateIsWeekend($date); unshift @dates, $date; unshift @{ $data[0] }, Statistics::FormatDate($Statistics::TimeToResolveLabelDateFormat, $date); }