|
|
|
|
@ -320,15 +320,18 @@ class NewsletterStatistics(DetailView): |
|
|
|
|
return context |
|
|
|
|
|
|
|
|
|
def get_stat_data(self, params={}): |
|
|
|
|
sent = self.object.contactmailingstatus_set.filter(status=ContactMailingStatus.SENT, **params).count() |
|
|
|
|
errors = self.object.contactmailingstatus_set.filter(status=ContactMailingStatus.ERROR, **params).count() |
|
|
|
|
opened = self.object.contactmailingstatus_set.filter(status=ContactMailingStatus.OPENED, **params).\ |
|
|
|
|
qs = self.object.contactmailingstatus_set |
|
|
|
|
sent = qs.filter(status=ContactMailingStatus.SENT, **params).count() |
|
|
|
|
errors = qs.filter(status=ContactMailingStatus.ERROR, **params).count() |
|
|
|
|
_opened_qs = qs.filter(status=ContactMailingStatus.OPENED, **params).\ |
|
|
|
|
values_list('contact', flat=True) |
|
|
|
|
opened = _opened_qs.distinct().count() |
|
|
|
|
opened_all = _opened_qs.count() |
|
|
|
|
unsubscribed = qs.filter(status=ContactMailingStatus.UNSUBSCRIPTION, **params).\ |
|
|
|
|
values_list('contact', flat=True).distinct().count() |
|
|
|
|
unsubscribed = self.object.contactmailingstatus_set.filter(status=ContactMailingStatus.UNSUBSCRIPTION, **params).\ |
|
|
|
|
values_list('contact', flat=True).distinct().count() |
|
|
|
|
no_data = self.object.contactmailingstatus_set.filter(status=ContactMailingStatus.ANNOUNCE_NO_DATA, **params).count() |
|
|
|
|
links = self.object.contactmailingstatus_set.filter(status=ContactMailingStatus.LINK_OPENED, **params).count() |
|
|
|
|
links_unique = self.object.contactmailingstatus_set.filter(status=ContactMailingStatus.LINK_OPENED, **params).\ |
|
|
|
|
no_data = qs.filter(status=ContactMailingStatus.ANNOUNCE_NO_DATA, **params).count() |
|
|
|
|
links = qs.filter(status=ContactMailingStatus.LINK_OPENED, **params).count() |
|
|
|
|
links_unique = qs.filter(status=ContactMailingStatus.LINK_OPENED, **params).\ |
|
|
|
|
values_list('contact', flat=True).distinct().count() |
|
|
|
|
CMS = ContactMailingStatus |
|
|
|
|
opened_percent = 0 if opened or sent == 0 else (float(opened)/sent)*100 |
|
|
|
|
@ -337,7 +340,7 @@ class NewsletterStatistics(DetailView): |
|
|
|
|
stat = { |
|
|
|
|
'sent': {'data': sent, 'filter': ""}, |
|
|
|
|
'errors': {'data': errors, 'filter': CMS.ERROR}, |
|
|
|
|
'opened': {'data': opened, 'filter': CMS.OPENED, 'percent': opened_percent}, |
|
|
|
|
'opened': {'data': opened, 'data_all': opened_all, 'filter': CMS.OPENED, 'percent': opened_percent}, |
|
|
|
|
'unsub': {'data': unsubscribed, 'filter': CMS.UNSUBSCRIPTION, 'percent': unsub_percent}, |
|
|
|
|
'no_data': {'data': no_data, 'filter': CMS.ANNOUNCE_NO_DATA}, |
|
|
|
|
'links': {'data': links, 'filter': CMS.LINK_OPENED}, |
|
|
|
|
|