mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
feat: expose active sessions in stats endpoint
This commit is contained in:
parent
9974852975
commit
1981f73212
2 changed files with 6 additions and 0 deletions
|
@ -183,6 +183,7 @@ def test_stats_empty(client):
|
||||||
"maps_count": 0,
|
"maps_count": 0,
|
||||||
"users_active_last_week_count": 0,
|
"users_active_last_week_count": 0,
|
||||||
"users_count": 0,
|
"users_count": 0,
|
||||||
|
"active_sessions": 0,
|
||||||
"version": VERSION,
|
"version": VERSION,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,6 +200,7 @@ def test_stats_basic(client, map, datalayer, user2):
|
||||||
"maps_count": 1,
|
"maps_count": 1,
|
||||||
"users_active_last_week_count": 1,
|
"users_active_last_week_count": 1,
|
||||||
"users_count": 2,
|
"users_count": 2,
|
||||||
|
"active_sessions": 0,
|
||||||
"version": VERSION,
|
"version": VERSION,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ from django.contrib.auth import BACKEND_SESSION_KEY, get_user_model
|
||||||
from django.contrib.auth import logout as do_logout
|
from django.contrib.auth import logout as do_logout
|
||||||
from django.contrib.gis.measure import D
|
from django.contrib.gis.measure import D
|
||||||
from django.contrib.postgres.search import SearchQuery, SearchVector
|
from django.contrib.postgres.search import SearchQuery, SearchVector
|
||||||
|
from django.contrib.sessions.models import Session
|
||||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
|
@ -1382,6 +1383,9 @@ def stats(request):
|
||||||
"users_active_last_week_count": User.objects.filter(
|
"users_active_last_week_count": User.objects.filter(
|
||||||
last_login__gt=last_week
|
last_login__gt=last_week
|
||||||
).count(),
|
).count(),
|
||||||
|
"active_sessions": Session.objects.filter(
|
||||||
|
expire_date__gt=datetime.utcnow()
|
||||||
|
).count(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue