Cached and fixed statistics

This commit is contained in:
Raphael Michel
2015-08-15 14:31:09 +02:00
parent b648d161d6
commit 9720cd8fea
2 changed files with 93 additions and 70 deletions

View File

@@ -4,10 +4,11 @@ from django.template import Context
from django.template.loader import get_template
from django.utils.translation import ugettext_lazy as _
from pretix.base.signals import order_paid, order_placed
from pretix.control.signals import html_head, nav_event
@receiver(nav_event)
@receiver(nav_event, dispatch_uid="statistics_nav")
def control_nav_import(sender, request=None, **kwargs):
url = resolve(request.path_info)
if not request.eventperm.can_view_orders:
@@ -25,7 +26,7 @@ def control_nav_import(sender, request=None, **kwargs):
]
@receiver(html_head)
@receiver(html_head, dispatch_uid="statistics_html_head")
def html_head_presale(sender, request=None, **kwargs):
url = resolve(request.path_info)
if url.namespace == 'plugins:statistics':
@@ -34,3 +35,14 @@ def html_head_presale(sender, request=None, **kwargs):
return template.render(ctx)
else:
return ""
def clear_cache(sender, *args, **kwargs):
cache = sender.get_cache()
cache.delete('statistics_obd_data')
cache.delete('statistics_obp_data')
cache.delete('statistics_rev_data')
order_placed.connect(clear_cache)
order_paid.connect(clear_cache)