[rt-devel] Time difference between certain transaction types
rt-devel
rt-devel at lists.netways.de
Fri May 30 10:31:25 EDT 2003
Hi list,
for reporting I am trying to get time differences between certain transaction types, e.g. I would like to know the time between "Take" and "stalled" or "resolved". Right now, I do the following, but it produces negative results, when a ticket is stalled first and taken later. Maybe someone knows a solution that respects the order :-)
# define minutes
my $seconds = 0;
my $minutes = 0;
my $start;
my $end;
# Get all transactions of this ticket
my $Transactions = $self->Transactions;
# order by created timestamp
$Transactions->OrderBy(FIELD => 'Created', ORDER => 'ASC');
# loop through all of them
while (my $Transaction = $Transactions->Next) {
if ($Transaction->Type eq "Take") {
$start = $Transaction->CreatedObj;
}
if ($Transaction->NewValue eq "stalled" || $Transaction->NewValue eq "resolved") {
$end = $Transaction->CreatedObj;
}
if ($start && $end) {
$seconds += $end->Diff($start);
$start = undef;
$end = undef;
}
}
# Get minutes and round
$minutes = int($seconds / 60);
Thanks,
Julian
__________________________________________________________
Julian Hein NETWAYS GmbH
Managing Director Deutschherrnstr. 47a
Fon.0911/92885-0 D-90429 Nürnberg
Fax.0911/92885-31
jhein at netways.de www.netways.de
More information about the Rt-devel
mailing list