Summarize data

Please, check my code!
I forgot to include some kind of readme.st. To test custom command:
python manage.py summarize [date YYYY-MM-DD] [--nodeletion]
If you pass no parameters it summarizes current date minus 15 days (single day and no a 15-days period)
It's a performance matter. You can't compute the average/mean until you got
all the values but you can use the loop for getting max and min values. I
agree that it's more readable and I'll change it.

I still need both host_max_response_time and host_min_response_time in
order to assign them to hosts_data structure although I could compute them
into the assignment. (and even with host_avg_response_time)

On Mon, Oct 6, 2014 at 8:54 PM, Lorenzo Gil Sanchez <
notifications@github.com> wrote:

> In okapiweb/management/commands/summarize.py:
>
> > +                paths_dict[urlparse(host.url).path].append(host)
> > +                host_response_time_list.append(host.response_time)
> > +                if host.status_code == 200:
> > +                    host_status_200 += 1
> > +                if host.status_code == 400:
> > +                    host_status_400 += 1
> > +                if host.status_code == 404:
> > +                    host_status_404 += 1
> > +                if host.status_code == 500:
> > +                    host_status_500 += 1
> > +                if host.response_time > host_max_response_time:
> > +                    host_max_response_time = host.response_time
> > +                if host.response_time < host_min_response_time:
> > +                    host_min_response_time = host.response_time
> > +
> > +            host_mean_response_time = average(host_response_time_list)
>
> For some things (host_mean_response_time) you are not computing that on
> the loop but computing it using a separate function that will iterate over
> the host_response_time_list at the end of the loop.
>
> Now, for other things like host_max_response_time you are doing it inside
> the loop instead of using the max/min functions at the end of the loop.
>
> I would prefer the pattern of using aggregate functions at the end of the
> loop. It's less performant but more readable. It just increase the constant
> k in the O(n) notation so performance wise, it's not a big deal in my
> opinion.
>
> This way you won't need the host_max_response_time and
> host_min_response_time variables.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/redbeacon/okapi-web/pull/23/files#r18477038>.
>



-- 
Alejandro Garcia
Software Engineer at RedBeacon.com