You could use the same logic and not restrict on resolved, but not sure
how you'd know not to double-count any time put in by adjusting the
Tickets.TimeWorked directly. It could also be adjusted downwards as
well, which raises all sorts of
other questions about where that would get subtracted from. Adjustments
made to TimeWorked do cause a transaction to be created, it just
doesn't populate the TimeTaken field of the transaction. <br><br>Now
that I think about it, that might be the simplest solution, beacuse
most of the complexity comes from trying to accurately deal with direct
adjustments made to the Tickets.TimeWorked field.<br>
<br>Anyone from BestP that could weigh in on the consequences of having
a change to TimeWorked also record the different in
Transactions.TimeTaken?<br><br><div class="gmail_quote">On Tue, Mar 3, 2009 at 9:52 AM, Alex Young <span dir="ltr"><<a href="mailto:alexyoung@scoutsolutions.co.uk">alexyoung@scoutsolutions.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div link="blue" vlink="purple" lang="EN-GB">
<div>
<p><span style="font-size: 10pt; color: rgb(31, 73, 125);">Looks like that would work to me. Though I would need to get the
time taken no matter what the status is as I was aiming at pulling the info out
for time sheets for the developers and support department so the accounts
department can invoice clients. At the moment RT users are putting all their
work in RT, and then putting their time in a separate timesheet, which
management then compile and give to accounts. </span></p>
<p><span style="font-size: 10pt; color: rgb(31, 73, 125);"> </span></p>
<p><span style="font-size: 10pt; color: rgb(31, 73, 125);">It would be very useful to have a time sheet extension for this
purpose, and most of the code and info must already be available in RT to do
this.</span></p>
<p><span style="font-size: 10pt; color: rgb(31, 73, 125);"> </span></p>
<p><span style="font-size: 10pt; color: rgb(31, 73, 125);"> </span></p>
<p><span style="font-size: 10pt; color: rgb(31, 73, 125);"> </span></p>
<div style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0cm 0cm;">
<p><b><span style="font-size: 10pt;" lang="EN-US">From:</span></b><span style="font-size: 10pt;" lang="EN-US"> Stephen Cochran
[mailto:<a href="mailto:stephen.a.cochran.lists@cahir.net" target="_blank">stephen.a.cochran.lists@cahir.net</a>] <br>
<b>Sent:</b> 03 March 2009 14:27<br>
<b>To:</b> Alex Young<br>
<b>Subject:</b> Re: [rt-users] Time Worked Report</span></p>
</div><div><div></div><div class="h5">
<p> </p>
<p style="margin-bottom: 12pt;">Thinking through this, the only
way to be completely accurate list of time spend in some given time_window
would be the following (in psudo sql):<br>
<br>
# total time worked in time_window from transactions<br>
select SUM(Transactions.TimeTaken) from ...<br>
where (Tickets.status = open or stalled or new) and<br>
Transactions.Created is within time_window<br>
<br>
+ <br>
<br>
# get total time worked from tickets resolved in time_window<br>
select Tickets.TimeWorked from ....<br>
where (Tickets.status = resolved) and<br>
Tickets.Resolved is within time_window<br>
<br>
- <br>
<br>
# subtract time from all transactions from tickets resolved in time_window<br>
select SUM(Transactions.TimeTaken) from ...<br>
where (Tickets.status = resolved) and<br>
Tickets.Resolved is within time_window and<br>
Transactions.ObjectId = Tickets.id<br>
<br>
This will capture all times entered directly into the TimeWorked field of the
ticket as occurring during the time_window when the ticket was resolved. Probably
fairly accurate, and would never be double counted.<br>
<br>
Anyone see a flaw in this? Still think this is harder than it should be.
Explains why RT hasn't had these reports already ;)<br>
<br>
</p>
<div>
<p>On Tue, Mar 3, 2009 at 4:28 AM, Alex Young <<a href="mailto:alexyoung@scoutsolutions.co.uk" target="_blank">alexyoung@scoutsolutions.co.uk</a>>
wrote:</p>
<div>
<div>
<p><span style="font-size: 10pt; color: rgb(31, 73, 125);">I had a bit of a go at doing
this myself. It needs some more work as it doesnt take into account if time has
been removed from a ticket. It happens sometimes because of typos etc.</span></p>
<p><span style="font-size: 10pt; color: rgb(31, 73, 125);"> </span></p>
<p><span style="font-size: 10pt; color: rgb(31, 73, 125);">If you get anywhere with this
please share it, as I havent had the time to work on it further.</span></p>
<p><span style="font-size: 10pt; color: rgb(31, 73, 125);"> </span></p>
<p><span style="font-size: 10pt; color: rgb(31, 73, 125);">PRNumber is an internal
reference number that we book client work too, so you wont need that, or you
can change it for something else.</span></p>
<p><span style="font-size: 10pt; color: rgb(31, 73, 125);"> </span></p>
<p><span style="font-size: 10pt; font-family: Consolas;">SELECT distinct
SUM(Transactions.TimeTaken) AS 'Time Taken (Mins)', Transactions.Created,
Users.RealName, Tickets.Subject, Queues.Name AS 'Queue Name',
Transactions.ObjectId AS 'Ticket ID',</span></p>
<p><span style="font-size: 10pt; font-family: Consolas;">(select
ObjectCustomFieldValues.Content from ObjectCustomFieldValues where
ObjectCustomFieldValues.CustomField = '11' and Transactions.ObjectId =
ObjectCustomFieldValues.ObjectId order by ObjectCustomFieldValues.id desc LIMIT
1) AS PRNumber</span></p>
<p><span style="font-size: 10pt; font-family: Consolas;">FROM Transactions</span></p>
<p><span style="font-size: 10pt; font-family: Consolas;">LEFT JOIN Users</span></p>
<p><span style="font-size: 10pt; font-family: Consolas;">ON Transactions.Creator
= Users.Id</span></p>
<p><span style="font-size: 10pt; font-family: Consolas;">LEFT JOIN Tickets</span></p>
<p><span style="font-size: 10pt; font-family: Consolas;">ON Transactions.ObjectId
= Tickets.id</span></p>
<p><span style="font-size: 10pt; font-family: Consolas;">LEFT JOIN Queues</span></p>
<p><span style="font-size: 10pt; font-family: Consolas;">ON Tickets.Queue =
Queues.Id</span></p>
<p><span style="font-size: 10pt; font-family: Consolas;">WHERE
Transactions.TimeTaken !=0</span></p>
<p><span style="font-size: 10pt; font-family: Consolas;">AND
DATE_SUB(CURDATE(),INTERVAL 15 DAY) <= Transactions.Created</span></p>
<p><span style="font-size: 10pt; font-family: Consolas;">GROUP BY Subject;</span></p>
<p><span style="font-size: 10pt; color: rgb(31, 73, 125);"> </span></p>
<p><span style="font-size: 10pt; color: rgb(31, 73, 125);"> </span></p>
<div style="border-style: solid none none; border-color: -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0cm 0cm;">
<p><b><span style="font-size: 10pt;" lang="EN-US">From:</span></b><span style="font-size: 10pt;" lang="EN-US"> <a href="mailto:rt-users-bounces@lists.bestpractical.com" target="_blank">rt-users-bounces@lists.bestpractical.com</a>
[mailto:<a href="mailto:rt-users-bounces@lists.bestpractical.com" target="_blank">rt-users-bounces@lists.bestpractical.com</a>] <b>On Behalf Of </b>Stephen
Cochran<br>
<b>Sent:</b> 03 March 2009 05:01<br>
<b>To:</b> rt Users<br>
<b>Subject:</b> [rt-users] Time Worked Report</span></p>
</div>
<div>
<div>
<p> </p>
<p><br>
I've written a sql query to pull out the time worked for all tickets resolved
in the last week among other things. The problem with this is that it doesn't
give a complete picture of time worked for any given week since a ticket could
have had time worked put in as part of a transaction but the ticket might still
be open. I could query the Transactions table for the TimeTaken field, but that
could lead to double-counting if any of those transactions are part of a
resolved ticket. <br>
<br>
I know I could work through the db/sql and find the right query to pull out the
time worked in the last week, but I'm wondering if someone else has already
done it so I can save myself the trouble.<br>
<br>
Thanks, <br>
Steve</p>
</div>
</div>
</div>
</div>
</div>
<p> </p>
</div></div></div>
</div>
</blockquote></div><br>