1 <& /Elements/Header, Title => 'Time to Resolution' &>
2 <& /RTx/Statistics/Elements/Tabs, Title => loc("Time To Resolve tickets by Queue for : " .$QueueObj->Name()) &>
4 <p>This page shows details of resolution of tickets in the selected queue. It displays tickets created on each day in your selected date
5 range. Of those tickets created on that day, how many have been resolved and the total time it has taken for all tickets created on that
6 day to be resolved.</p>
7 <p>At the bottom of the chart is shows total time taken to resolve all tickets
8 in the selected date range and the average time per ticket to
11 <form method="POST" action="index.html">
13 %my $title = "Time to resolve in " . $QueueObj->Name() . " per day from " .
14 % Statistics::FormatDate($Statistics::PerDayDateFormat, $dates[0]) . " through " .
15 % Statistics::FormatDate($Statistics::PerDayDateFormat, $dates[$#dates-1]);
16 <&|/Elements/TitleBox,
18 title_href => $RT::WebPath ."/RTx/Statistics/Resolution/index.html?$QueryString" &>
19 <TABLE BORDER=0 cellspacing=0 cellpadding=1 WIDTH=100%>
21 <& /RTx/Statistics/Elements/CollectionAsTable/Header,
23 FormatString => $Format,
24 AllowSorting => $AllowSorting,
31 maxitems => $maxitems &>
34 % LINE: for my $d (0..$#dates ) {
35 % if ($d == $#dates ){
39 % $values{Statistics_Date} = Statistics::FormatDate($Statistics::PerDayDateFormat, $dates[$d]);
40 % my $tix = new RT::Tickets($session{'CurrentUser'});
41 % $tix->LimitCreated(VALUE => $dates[$d]->ISO, OPERATOR => ">=");
43 % $tix->LimitCreated(VALUE => $dates[$d+1]->ISO, OPERATOR => "<=");
46 % $tix->LimitQueue (VALUE => $Queue);
48 % $values{Statistics_Created_Count} = $tix->Count;
49 % $tix->LimitStatus(VALUE => "resolved");
50 % $values{Statistics_Resolved_Count} = $tix->Count;
52 % my @tix = @{$tix->ItemsArrayRef};
54 % $total += ($_->ResolvedObj->Unix - $_->CreatedObj->Unix) for @tix;
56 % $grandtotal += $total;
57 % $values{Duration} = Statistics::DurationAsString($total);
58 % $data[$x++][$d] = int ($total );
60 % $values{Duration} = "N/A";
62 <& /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@Format, i => $line, record => $record, maxitems => $maxitems &>
65 % $size =1 if $size==0;
66 % $values{text} = "Average time to resolve = " . Statistics::DurationAsString($grandtotal / $size);
67 <& /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@OneCellFormat, i => $line, record => $record, maxitems => $maxitems &>
69 % $values{text} = "Total time to resolve = " . Statistics::DurationAsString( $grandtotal );
70 <& /RTx/Statistics/Elements/CollectionAsTable/Row, Format => \@OneCellFormat, i => $line, record => $record, maxitems => $maxitems &>
76 # Create the graph URL
78 # change the total time to resolve to a floating point number of days
79 foreach my $dat(@{$data[1]} ){
80 $dat = ($dat / $Statistics::secsPerDay);
81 $dat = sprintf("%0.4f", $dat);
84 my $url = 'Elements/Chart?x_labels=';
86 $url .= $data[0][$_] . ",";
92 $data[0][$_] = 0 if !$data[0][$_];
93 $url .= $data[0][$_] . ",";
97 <& /RTx/Statistics/Elements/GraphBox, GraphURL => $url &>
99 <& /RTx/Statistics/Elements/ControlsAsTable/ControlBox,
100 Title => "Change Queue or Dates",
101 ShowDates => 1, sMonth => \$sMonth, sDay => \$sDay, sYear => \$sYear,
102 eMonth => \$eMonth, eDay => \$eDay, eYear => \$eYear,
103 weekends => $weekends,
104 ShowSingleQueue => 1, Queue => $Queue
109 <% Statistics::DebugInit($m) |n %>
112 $max => $Statistics::TimeToResolveMaxRows
114 $weekends =>$Statistics::TimeToResolveWeekends
124 $AllowSorting => undef
152 my $record = \%record;
154 $record{values} = \%values;
157 # If debugging, set things up and display all the args
158 Statistics::DebugClear();
159 Statistics::DebugLog("CallsQueueDay/index.html ARGS:\n");
160 for my $key (keys %ARGS) {
161 Statistics::DebugLog("ARG{ $key }=" . $ARGS{$key} . "\n");
164 my $Format = qq{ Statistics_Date,
165 '__Statistics_Created_Count__/STYLE:text-align:right;',
166 '__Statistics_Resolved_Count__/STYLE:text-align:right;',
167 '__Statistics_Dynamic__/KEY:Duration/TITLE:Time To Resolve/STYLE:text-align:right;' };
168 my $BoldFormat = qq{ '<B>__Statistics_Date__</B>',
169 '<B>__Statistics_Created_Count__</B>/STYLE:text-align:right;',
170 '<B>__Statistics_Resolved_Count__</B>/STYLE:text-align:right;',
171 '<B>__Statistics_Dynamic__</B>/KEY:Duration/TITLE:Time To Resolve/STYLE:text-align:right;' };
173 # TODO need way to make this cell do colspan
174 my $OneCellFormat = qq{ '<B>__Statistics_Dynamic__</B>/KEY:text/STYLE:text-align:left;','','','' };
176 my (@Format) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $Format);
177 my (@BoldFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $BoldFormat);
178 my (@OneCellFormat) = $m->comp('/RTx/Statistics/Elements/CollectionAsTable/ParseFormat', Format => $OneCellFormat);
180 Statistics::DebugLog("CallsQueueDay/index.html Format array=" . join(',', @Format) . "\n");
182 if ($sDay > $Statistics::monthsMaxDay{$sMonth}) {
183 $sDay = $Statistics::monthsMaxDay{$sMonth};
186 if ($eDay > $Statistics::monthsMaxDay{$eMonth}) {
187 $eDay = $Statistics::monthsMaxDay{$eMonth};
191 $sEpoch = timelocal(0, 0, 0, $sDay, $sMonth, $sYear-1900);
194 Statistics::DebugLog("eMonth = " . $eMonth . "\n");
195 $eEpoch = timelocal(0, 0, 0, $eDay, $eMonth, $eYear-1900);
197 # This case happens when the page is first loaded
198 my @local = localtime(time);
199 ($eDay, $eMonth, $eYear) = ($local[3], $local[4], $local[5]);
201 $eEpoch = timelocal(0, 0, 0, $local[3], $local[4], $local[5], $local[6], $local[7], $local[8]);
202 Statistics::DebugLog("Setting eEpoch=$eEpoch from current time.\n");
205 if (($eEpoch < $sEpoch) || ($sEpoch == 0)) {
206 # We have an end, but not a start, or, overlapping.
208 # if $currentMonth is set, just set the day to 1
210 # set start vars from end, but with day set to 1
211 (undef, undef, undef, $sDay, $sMonth, $sYear) = localtime($eEpoch);
213 $sEpoch = timelocal(0, 0, 0, $sDay, $sMonth, $sYear);
215 # If the user has specified how many days back to go, use that,
216 # If not, set start to configured default period before end
218 $sEpoch = $eEpoch - ($days * $Statistics::secsPerDay);
220 $sEpoch = $eEpoch - ($Statistics::PerDayPeriod * $Statistics::secsPerDay);
222 (undef, undef, undef, $sDay, $sMonth, $sYear) = localtime($sEpoch);
227 # Compute days to chart.
228 # The +1 is because we need to generate one more date. If the user
229 # selected a 10 day range, we need to generate 11 days.
230 $diff = int(($eEpoch - $sEpoch + $Statistics::secsPerDay - 1) / $Statistics::secsPerDay)+1;
231 Statistics::DebugLog("Setting diff=$diff\n");
233 Statistics::DebugLog("sEpoch=$sEpoch, components=" . join(',', localtime($sEpoch)) . "\n");
234 Statistics::DebugLog("eEpoch=$eEpoch, components=" . join(',', localtime($eEpoch)) . "\n");
236 my $QueueObj = new RT::Queue($session{'CurrentUser'});
237 if (!defined $Queue) {
238 $QueueObj->Load($Statistics::TimeToResolveQueue);
239 $Queue = $QueueObj->Id();
242 # Set up the string for the current query for bookmarkable link
243 $QueryString = "sDay=$sDay&sMonth=$sMonth&sYear=$sYear&eDay=$eDay&eMonth=$eMonth&eYear=$eYear&weekends=$weekends&Queue=$Queue";
245 # Set up the end date to be midnight(morning) of the date after the one the user wanted.
246 my $endRange = $eEpoch + $Statistics::secsPerDay;
247 $QueueObj->Load($Queue);
248 # NOTE: list loop starts at the end of the date range, unshifting dates onto
249 # the arrays, so that they end up in start to finish order.
250 $eEpoch += $Statistics::secsPerDay;
252 until ($#dates == $diff ) {
253 my $date = new RT::Date($session{CurrentUser});
254 $date->Set(Value=>$endRange - $n, Format => 'unix');
255 # Note: we used to adjust the time to local midnight, but
256 # none of the other date entry fields in RT seem to adjust, so we've stopped.
257 #Statistics::DebugLog("Before adjust to midnight date " . Statistics::FormatDate("%c", $date) . "\n");
258 $n+= $Statistics::secsPerDay;
259 # If we aren't showing weekends and this is one, decrement the number
260 # of days to show and skip to the next date.
261 if(!$weekends and Statistics::RTDateIsWeekend($date)) {$diff--; next;}
262 unshift @dates, $date;
263 Statistics::DebugLog("pushing date " . Statistics::FormatDate("%c", $date) . "\n");
264 unshift @{ $data[0] }, Statistics::FormatDate($Statistics::PerDayLabelDateFormat, $date);