emencia / emencia-django-newsletter

An app for sending newsletter by email to a contact list.
189 stars 72 forks source link

ZeroDivisionError #9

Closed geokollias closed 14 years ago

geokollias commented 14 years ago

A ZeroDivisionError could happen @ get_newsletter_opening_statistics view @ utils/statistics.py, if all newsletter's mailling list's subscribers have unsubscribed.

Fantomas42 commented 14 years ago

Effectively this bug can occur. I will write some tests to reproduce the problem and solve it.

Thank you for the report. Is it a real case ?

geokollias commented 14 years ago

Fortunately, it occurred during manual testing :) Btw, thank you for such a useful app.

Fantomas42 commented 14 years ago

Test writed, bug fixed. 20651fba05701bba6651f3b6e1989d39c24e6c3f

geokollias commented 14 years ago

Perfect. Thnx :)

Also, in my machine, tests break at test_expedition_set() because 'unsubscribers_id' in 'MailingList.expedition_set()' is a ValuesListQuerySet and 'exclude(id__in=unsubscribers_id)' doesn't seem to work well with it (it doesn 't see the contacts' ids). However, when i change it to a pure list of ints ('exclude(id__in=[id for id in unsubscribers_id])'), i dont have any problem. Do you face the same problem?

Fantomas42 commented 14 years ago

It's strange because I didn't have the problem, and values_list with flat=True, must return a list.

Which version of Django do you use ? How do you launch the tests ?

geokollias commented 14 years ago

values_list with flat=True return ValuesListQuerySet to me. I use version 1.2.1 and i launch them with django's 'manage.py test'

Fantomas42 commented 14 years ago

Ok, can you report this in another issue, with a dump of your datas ?