[rt-users] find time span between dates

Raed El-Hames rfh at vialtus.com
Fri Apr 16 15:03:41 EDT 2010


Gareth;

I have n't my actual scrip to hand at the moment but the below should work ;
Create global custom field (field that applies to all queues) and call 
it "TimeToUpdate"

Create global scrip:
Scrip Condition: On Status Change
Scrip Action: User defined

Custom action preparation code: 
    if ($self->TransactionObj->NewValue eq 'open' and 
$self->TransactionObj->OldValue eq 'new') {
       return 1;
   } else {
       return undef;
   }

Custom action cleanup code:
  my $cf_v = $self->TicketObj->FirstCustomFieldValue('TimeToUpdate');
  if (($cf_v) && ($cf_v != '')) {
       return undef;
   }
   my $now = new RT::Date($RT::SystemUser);
   $now->SetToNow();
   my $createdObj = $self->TicketObj->CreatedObj ;
   my $diff = $now->Diff($createdObj);
   my $cf_obj = RT::CustomField->new(RT::SystemUser);
   $cf_obj->LoadByName(Name=> 'TimeToUpdate');
   $cf_obj->AddValueForObject(Object => $self->TicketObj, Content => $diff);
   return 1;
  
  
By the way ->Diff will populate the field with number of seconds ; I 
think in Date.pm there is a method
->DiffAsString that you can use instead of ->Diff  which gives you human 
readable difference

Regards;
Roy


Gareth Tupper wrote:
> Hi Roy
>
> If you wouldn't mind, could you share the scrip that you used to accomplish this?  I'm just setting up a small RT installation & those metrics seem like they would be great to start recording.
>
> Cheers,
> Gareth
>
> -----Original Message-----
> From: rt-users-bounces at lists.bestpractical.com [mailto:rt-users-bounces at lists.bestpractical.com] On Behalf Of Raed El-Hames
> Sent: Friday, April 16, 2010 6:02 AM
> To: Steven Platt
> Cc: rt-users at lists.bestpractical.com
> Subject: Re: [rt-users] find time span between dates
>
> Steven;
>
> As far as I know there is n't ; what I did is create a global custom 
> field , and a global scrip that populates its values with condition on 
> Status change from new to open, and the action  is user defined 
> subtracting the unix time now - the unix created time; then populating 
> the field (in seconds).
> Our tickets hardly go back to new once are opened , but an if to see if 
> the custom field is empty will be a good safe guard.
>
> Obviously this is only useful going forward, for existing tickets you 
> will need to write a script (perl/whatever), pull the tickets you need 
> and work out
> Started - Created then populate the field, its fairly straight forward 
> with Perl and the RT api.
>
> Regards;
> Roy
>
> Steven Platt wrote:
>   
>> Hi,
>>
>> Is there a way to report the difference between RT dates (Created & 
>> Started) , either in the standard or advanced search ?
>>
>> I ' m looking to generate a report to reflect how rapidly requests are 
>> addressed by our support staff.
>>
>> Many thanks
>>
>> Steve
>>
>> [RT v3.6.2]
>>
>> Dr Steven Platt
>>
>> Bioinformatician
>>
>> Statistics, Modelling and Bioinformatics
>>
>> Health Protection Agency
>>
>> Centre for Infections
>>
>> London
>>
>> www.hpa.org.uk/bioinformatics <http://www.hpa.org.uk/bioinformatics>
>>
>> * 
>> ************************************************************************** 
>> The information contained in the EMail and any attachments is 
>> confidential and intended solely and for the attention and use of the 
>> named addressee(s). It may not be disclosed to any other person 
>> without the express authority of the HPA, or the intended recipient, 
>> or both. If you are not the intended recipient, you must not disclose, 
>> copy, distribute or retain this message or any part of it. This 
>> footnote also confirms that this EMail has been swept for computer 
>> viruses, but please re-sweep any attachments before opening or saving. 
>> HTTP://www.HPA.org.uk 
>> ************************************************************************** 
>> *
>>
>>     
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
>   



More information about the rt-users mailing list