[rt-users] Calculating the number of emails/replies/correspondences per ticket

Landon Stewart lstewart at internap.com
Tue Oct 4 15:23:58 EDT 2016


On Oct 4, 2016, at 10:28 AM, Anthony Nguyen-Duong <anthnd at hotmail.com<mailto:anthnd at hotmail.com>> wrote:


Hi,

I'd like to find out how to add my own calculation to charts, as opposed to the limited Ticket Count and various time calculations available for charts.
I'd like to add a calculation that calculates the number of emails/correspondences between an agent and a customer. I've tried looking through "lib/RT/Report/Tickets.pm" and "share/html/Search/Chart.html", but there's a lot of things I don't understand in there.

Now, realistically I may not have to go through the effort of adding a calculation for charts.
My end result is a table that has the columns: TicketId, NumberOfEmails (and I'll probably add some other things like Subject and whatnot). However, I'd prefer not to have a Custom Field for NumberOfEmails, reason being I'm not sure if there's a way to calculate the number of emails for all my past tickets and set all of them to their correct value apart from manually counting and inputting it. Instead, I was considering doing Callbacks or something to count the number of Correspondences in the Transactions table from the database and appending a column to a table.

We have two CFs that are populated - ClientReplies, StaffReplies and can be used in the charts.  I've done this twice before with two different approaches.

The first approach worked like this:
A crontab would use an action which would do this for each ticket.  It would cycle through all the create and correspond transactions and attribute them to either staff or clients then update the CF when it was done.  This meant that every single create,correspond transaction was processed for every ticket every time it ran.  It was a wasteful way to do it.

The second approach worked like this:
Two conditions were created - One that detected 'staff' correspondence and another to detect 'client' (non-staff) correspondence.  Depending on which condition was true an action to increment the appropriate CF (read the current CF value, add 1, delete the old CF value, record the new CF value).  The net effect was that the CFs were updated only when it was necessary.  This is a much more efficient way to do it.

--
Landon Stewart
Lead Analyst - Abuse and Security Management
INTERNAP ®
📧 lstewart at internap.com<mailto:lstewart at internap.com>
🌍 www.internap.com<http://www.internap.com>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20161004/dfc780f2/attachment.htm>


More information about the rt-users mailing list