ludofleury / GuzzleBundle

Debug your API Calls with a Symfony web profiler for guzzle
http://ludofleury.github.io/GuzzleBundle/
MIT License
82 stars 21 forks source link

add a test to avoid a division by zero #18

Closed agallou closed 10 years ago

agallou commented 10 years ago

When the cacheplugin is used in guzzle, the total time of the request is zero.

So when calculating the percents in the debug bar there is an exception :

An exception has been thrown during the rendering of a template
("Warning: Division by zero in FILE) in
PlaybloomGuzzleBundle:Profiler:request.html.twig at line 15

To avoid this we do not calculate to percents nor display to time table (witch is irrelevant in this case).

ludofleury commented 10 years ago

Very good catch. I realize that this is a logic thing and could be processed in the data collector (and be tested).

What do you think ? I may refactor this.

agallou commented 10 years ago

I could also change my PR.

I would consist in calculate the percentages here https://github.com/ludofleury/GuzzleBundle/blob/master/DataCollector/GuzzleDataCollector.php#L66 with null as default values

Add it to the time array and use it in the request.html.twig (display them only if they are not null).

Is that right for you ?

ludofleury commented 10 years ago

I just reviewed the bundle, I strongly agree with you. Moreover, the profiler should be enriched to display a cache hit ? what do you think ?

Oh, note that this bundle may be merged here: https://github.com/misd-service-development/guzzle-bundle/pull/29 Is it a problem for you ?

Merry christmas!

ludofleury commented 10 years ago

Merged like this for the moment. thanks again for the fix.