浏览代码

HUE-8820 [stats] Adding daily query stats

Romain 6 年之前
父节点
当前提交
d0dfd13766
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      desktop/libs/notebook/src/notebook/models.py

+ 7 - 1
desktop/libs/notebook/src/notebook/models.py

@@ -475,11 +475,17 @@ class Analytics():
   @classmethod
   def admin_stats(cls):
     stats = []
+    one_day = datetime.date.today() - timedelta(days=1)
     one_week = datetime.date.today() - timedelta(weeks=1)
     one_month = datetime.date.today() - timedelta(days=30)
     three_months = datetime.date.today() - timedelta(days=90)
 
-    stats.append(('Last modified', '1 week'))
+    stats.append(('Last modified', '1 day'))
+    stats.append(('Users', User.objects.filter(last_login__gte=one_day).count()))
+    stats.append(('Sessions', Session.objects.filter(expire_date__gte=one_day).count()))
+    stats.append(('Executed queries', Document2.objects.filter(last_modified__gte=one_day, is_history=True, type__startswith='query-').count()))
+
+    stats.append(('\nLast modified', '1 week'))
     stats.append(('Users', User.objects.filter(last_login__gte=one_week).count()))
     stats.append(('Sessions', Session.objects.filter(expire_date__gte=one_week).count()))
     stats.append(('Executed queries', Document2.objects.filter(last_modified__gte=one_week, is_history=True, type__startswith='query-').count()))