Don't track included API requests.
authorRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Wed, 1 Oct 2014 08:39:02 +0000 (10:39 +0200)
committerRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Wed, 1 Oct 2014 08:39:02 +0000 (10:39 +0200)
apps/api/urls.py
apps/stats/utils.py

index e9b106c..1c2e656 100644 (file)
@@ -37,6 +37,7 @@ def incl(request, model, pk, emitter_format):
         'fragment': fragment_list_resource,
         'tag': tag_list_resource,
         }[model]
+    request.piwik_track = False
     resp = resource(request, pk=pk, emitter_format=emitter_format)
     if emitter_format == 'xml':
         # Ugly, but quick way of stripping <?xml?> header and <response> tags.
index 543f863..474d1b5 100644 (file)
@@ -47,7 +47,8 @@ def piwik_track(klass_or_method):
         call_func = klass_or_method
 
     def wrap(self, request, *args, **kw):
-        track_request.delay(piwik_url(request))
+        if getattr(request, 'piwik_track', True):
+            track_request.delay(piwik_url(request))
         return call_func(self, request, *args, **kw)
 
     # and wrap it