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 with Husseyin on this.  Sorry Alejandro for going back and forth
with this.

It doesn't make much sense to return True and then raise an exception
instead of False.

Either is_valid_date/True/False or check_date/None/exception, but not
combined.

On Fri, Oct 10, 2014 at 11:43 AM, Huseyin Yilmaz <notifications@github.com>
wrote:

> In okapiweb/management/commands/summarize.py:
>
> > +        make_option('--nodelete',
> > +                    action='store_true',
> > +                    dest='nodelete',
> > +                    default=False,
> > +                    help='Preserve processed data'),
> > +    )
> > +
> > +    def check_date(self, processed_date="", format_string=DEFAULT_DATE_FORMAT):
> > +        """Helper to check if a date is valid"""
> > +
> > +        output = True
> > +        try:
> > +            datetime.strptime(processed_date, format_string)
> > +        except ValueError:
> > +            output = False
> > +        return output
>
> I see,
> I considered this function as a predicate. So I was expecting it to return
> only Boolean. Exception is also a good idea. But I think if it raises an
> exception, it should not return True in success case. Because, we will only
> be interested in side effect of the function. Something like this maybe:
>
> try:
>     datetime.strptime(string_date, format_string)
> except ValueError:
>     raise CommandError('Date should have the right format YYYY-MM-DD')
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/redbeacon/okapi-web/pull/23/files#r18722988>.
>



-- 
Daniel Gonzalez Gasull
Software Engineer at RedBeacon.com