def handle(self, *args, **options): print('Starting...') stats = Analytics.admin_stats() msg = '\n'.join(['%s\t=\t%s' % stat for stat in stats]) mail.mail_admins(subject='Query Stats', message=msg, fail_silently=False) print('Done.')
def test_basic_stats(self): try: doc, created = Document2.objects.get_or_create(name='test_query_stats', type='query-hive', owner=self.user, data={}) Analytics.admin_stats() Analytics.user_stats(user=self.user) Analytics.query_stats(query=doc) finally: doc.delete()
def admin_stats(request): if is_admin(user=request.user): return JsonResponse({ 'admin_stats': Analytics.admin_stats() })