Am 20.02.2013 10:30, schrieb Emmanuel Lacour:
> - patch RT graphing system to do what you want, this is a bit more
>   tricky and may need a lot of cpu if you want to calculate you're value
>   on all ticket when graphing.

Part of this I have done for our RT 3.8.6. Attached a patch but DON'T
use this patch, it should you just show what I have done.

There is currently an branch [1] for 4.2 where BPS is working on new
reporting function and I really hope this new functions will land in RT
4.2 as it pushes the RT reporting features to the next level.

[1] https://github.com/bestpractical/rt/tree/4.2/charts-improvments
>From 79143877d2d153d6d0299acfc1794539ac3a82e9 Mon Sep 17 00:00:00 2001
From: Christian Loos <[email protected]>
Date: Tue, 19 Jul 2011 10:52:14 +0200
Subject: [PATCH] add DaysCreatedToResolved grouping

---
 lib/RT/Report/Tickets_Vendor.pm |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/lib/RT/Report/Tickets_Vendor.pm b/lib/RT/Report/Tickets_Vendor.pm
index a06e5a9..e5857df 100644
--- a/lib/RT/Report/Tickets_Vendor.pm
+++ b/lib/RT/Report/Tickets_Vendor.pm
@@ -16,7 +16,7 @@ sub Groupings {
         );
     }
 
-    # NOTE: reorder fields, add Weekly fields
+    # NOTE: reorder fields, add Weekly fields, add DaysCreatedToResolved field
     push @fields, map {$_, $_} qw(
         CreatedDaily CreatedWeekly CreatedMonthly CreatedAnnually
         StartsDaily StartsWeekly StartsMonthly StartsAnnually
@@ -24,6 +24,7 @@ sub Groupings {
         LastUpdatedDaily LastUpdatedWeekly LastUpdatedMonthly LastUpdatedAnnually
         DueDaily DueWeekly DueMonthly DueAnnually
         ResolvedDaily ResolvedWeekly ResolvedMonthly ResolvedAnnually
+        DaysCreatedToResolved
     );
 
     my $queues = $args{'Queues'};
@@ -113,6 +114,11 @@ sub _FieldToFunction {
             $self->{"_sql_report_watcher_users_alias_$type"} = $u_alias;
         }
         @args{qw(ALIAS FIELD)} = ($u_alias, $column);
+    # NOTE: add DaysCreatedToResolved function
+    # XXX Important: this works only for mysql!!!
+    } 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;
 }
-- 
1.7.2.5


-- 
RT training in Amsterdam, March 20-21: 
http://bestpractical.com/services/training.html

Help improve RT by taking our user survey: 
https://www.surveymonkey.com/s/N23JW9T

Reply via email to