Browse Source

HUE-3287 [core] Django 1.11 upgrade
- Fixing metrics chicken-egg issue for the migration

Prakash Ranade 7 years ago
parent
commit
9272fde2de
1 changed files with 5 additions and 1 deletions
  1. 5 1
      apps/useradmin/src/useradmin/metrics.py

+ 5 - 1
apps/useradmin/src/useradmin/metrics.py

@@ -20,7 +20,11 @@ from desktop.lib.metrics import global_registry
 
 def active_users():
   from useradmin.models import UserProfile
-  return UserProfile.objects.filter(last_activity__gt=datetime.now() - timedelta(hours=1)).count()
+  try:
+    count = UserProfile.objects.filter(last_activity__gt=datetime.now() - timedelta(hours=1)).count()
+  except:
+    count = 0
+  return count
 
 global_registry().gauge_callback(
     name='users.active',