Help calculating time to resolve

RT 3.2.2
MySQL 4.1.7-0

My company needs to report on time to resolve tickets, but we want to
exclude any amount of time the ticket may have spent in Hold status. To
make queries easier, my thought is to use a custom scrip action to calculate
the time to resolve when the ticket is resolved and store the value in
either the Time Worked field or a custom field.

To calculate the time to resolve excluding any Hold time, it seems to me
that I would need to step thru the ticket transactions in order, adding up
the time spent in New and Open status. I’m not a dev, but I was hoping that
someone had done something similar or could direct me to sample code where I
might get a clue how to start. I reviewed the WriteCustomAction page on the
wiki and it gives me hope that this can be done, I guess I just can’t see
how to access the ticket transactions and loop thru them. Any guidance much