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)
I agree. It's more readable.

On Sat, Oct 4, 2014 at 1:56 AM, Fidel Ramos <notifications@github.com>
wrote:

> In okapiweb/management/commands/summarize.py:
>
> > +        start_date = datetime.strptime(start_date, self.DEFAULT_DATE_FORMAT)
> > +        year = start_date.year
> > +        quarter = format(self.quarters[start_date.month], '02')
> > +        week = format(start_date.isocalendar()[self.WEEK], '02')
> > +        bucketed_date = start_date.strftime('%Y-%m-%d-day')
> > +        time_bucket = [
> > +            bucketed_date,
> > +            "{}-{}-week".format(year, week),
> > +            start_date.strftime('%Y-%m-month'),
> > +            "{}-{}-quarter".format(year, quarter),
> > +            start_date.strftime('%Y-year'),
> > +        ]
> > +
> > +        # Projects: get them by filtering the collections with _raw suffix
> > +        collections = []
> > +        [collections.append(col) for col in connection.get_db().collection_names() if col.endswith(self.RAW_SUFFIX)]
>
> This is wrong, list comprehensions shouldn't have side effects. I strongly
> recommend to turn this into a loop:
>
> for col in connection.get_db().collection_names():
>     if col.endswith(self.RAW_SUFFIX):
>         collections.append(col)
>
> It's more readable too IMO.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/redbeacon/okapi-web/pull/23/files#r18425505>.
>



-- 
Alejandro Garcia
Software Engineer at RedBeacon.com