![]() |
Response Time
I am trying to get this to properly give the average response time for tickets. Similar to what is on vb.com but for the life of me it won't work. Gives me -34613 hours and -14 mins, very annoying.
Here is the function: PHP Code:
PHP Code:
HTML Code:
$hour:$minute Thanks Steve |
What are the types in the database of pl9_support_tickets.tadded and pl9_support_replies.radded? Are they strings of the correct format? I'm thinking maybe they could already be numbers. You could easily look at this (if you haven't already) by building up a string then throwing it in the template somewhere (as an html comment maybe).
Also I don't think you want "round" on the hour calculation, I think you want to use floor() or else make sure you are dividing two integer values. |
kh99 is right; round is the wrong function to use:
http://uk3.php.net/manual/en/function.round.php round() will round 3.5 UP to 4. I think the logic of your function is off slightly as well, but I'm unable to figure out where. |
tadded and radded is unix time inserted into the database when a ticket is added or a reply is added. So round() is possibly causing the problem? So far any thing I found that deals with giving an average uses round.
|
Quote:
Quote:
hrs = 6300 / 3600 = 1.75, rounded up = 2 hrs, but floor(1.75) = 1 |
Ok so using my code above, any suggestion of a way to rewrite. I've stated this before but I learn best from example codes then discussion of various means. I understand what your saying but implementing is my problem. LOL
|
Well assuming I'm right about those time fields (and I'm not sure), I would say change these two lines to:
Code:
$rep = $query['radded']; Also, change this line to Code:
$hour = floor($avg/3600); |
Yeah they both are INT type, I believe they are unsigned. So this is what I should have:
PHP Code:
--------------- Added [DATE]1265060826[/DATE] at [TIME]1265060826[/TIME] --------------- Ok I tested the code, result was the following: Code:
-175695:10 |
ok, well if anyone else has an idea, feel free to jump in....
meanwhile, if it were me i'd find a way to display the values and see where they don't look right, like maybe.... PHP Code:
Then put $debug_tickets in the template somewhere. |
Ok I had to take it out of a function and make it a straight query just to get an output. Here is the output of the $debug_tickets:
Code:
tid=2 tadded=1265002705 radded= seconds=-1265002705 i=1 --------------- Added [DATE]1265079985[/DATE] at [TIME]1265079985[/TIME] --------------- BTW, the first line of tid=2, radded= is blank because no reply has been added to that ticket. --------------- Added [DATE]1265080418[/DATE] at [TIME]1265080418[/TIME] --------------- Reversed $seconds += ($rep - $tick) to ($tick - $rep) which gives me the following: Code:
tid=2 tadded=1265002705 radded= seconds=1265002705 i=1 Code:
175694:49 Added a reply to the tid=2 and this is the new output: Code:
tid=2 tadded=1265002705 radded=1265084927 seconds=-82222 i=1 |
Yeah, I think that's your problem - if radded is blank you shouldn't be including it in the average, right? You're subtracting the start time from 0 and ending up with a huge negative number. I think you need something like:
PHP Code:
|
Another test, I changed $rep - $tick back to normal and got this:
Code:
tid=3 tadded=1265085047 radded=1265085108 seconds=61 i=1 --------------- Added [DATE]1265081713[/DATE] at [TIME]1265081713[/TIME] --------------- Do I need this at all? PHP Code:
|
Quote:
|
Ah ok, overall then it is working, showing a high reply time but I assume that is due to the amount of tickets and the replies that are there since it is a testing enviroment.
|
yeah, you can see the debug output and you can actually do the math yourself. you have 3 tickets with reply times 61 seconds, about 22 hours, 0 seconds, so the average should be around 7 hours.
|
Yeah, pain pills kinda slows down my math skills. LOL
Its all good now, I have it giving an average for last 30 tickets and an average for a single ticket. Thanks for all the help. |
All times are GMT. The time now is 08:32 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|