Merge pull request #1153 from umap-project/version-stats

Expose version in /stats/ endpoint
This commit is contained in:
Yohan Boniface 2023-06-20 17:23:03 +02:00 committed by GitHub
commit db8c1f8699
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -8,6 +8,7 @@ from django.contrib.auth import get_user, get_user_model
from django.urls import reverse from django.urls import reverse
from django.test import RequestFactory from django.test import RequestFactory
from umap import VERSION
from umap.views import validate_url from umap.views import validate_url
@ -157,6 +158,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,
"version": VERSION,
} }
@ -172,6 +174,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,
"version": VERSION,
} }

View file

@ -883,6 +883,7 @@ def stats(request):
last_week = date.today() - timedelta(days=7) last_week = date.today() - timedelta(days=7)
return simple_json_response( return simple_json_response(
**{ **{
"version": VERSION,
"maps_count": Map.objects.count(), "maps_count": Map.objects.count(),
"maps_active_last_week_count": Map.objects.filter( "maps_active_last_week_count": Map.objects.filter(
modified_at__gt=last_week modified_at__gt=last_week