diff --git a/api/obs/api/routes/stats.py b/api/obs/api/routes/stats.py
index dfdbe7c..5875298 100644
--- a/api/obs/api/routes/stats.py
+++ b/api/obs/api/routes/stats.py
@@ -4,12 +4,12 @@ from typing import Optional
from operator import and_
from functools import reduce
-from sqlalchemy import select, func, desc
+from sqlalchemy import distinct, select, func, desc
from sanic.response import json
from obs.api.app import api
-from obs.api.db import Track, OvertakingEvent, User, Region
+from obs.api.db import Track, OvertakingEvent, User, Region, UserDevice
from obs.api.utils import round_to
@@ -92,6 +92,14 @@ async def stats(req):
.where(track_condition)
)
).scalar()
+ device_count = (
+ await req.ctx.db.execute(
+ select(func.count(distinct(UserDevice.id)))
+ .select_from(UserDevice)
+ .join(Track.user_device)
+ .where(track_condition)
+ )
+ ).scalar()
result = {
"numEvents": event_count,
@@ -100,6 +108,7 @@ async def stats(req):
"trackDuration": round_to(track_duration or 0, TRACK_DURATION_ROUNDING),
"publicTrackCount": public_track_count,
"trackCount": track_count,
+ "deviceCount": device_count,
}
return json(result)
diff --git a/frontend/src/components/Stats/index.tsx b/frontend/src/components/Stats/index.tsx
index ef0b3c2..b558930 100644
--- a/frontend/src/components/Stats/index.tsx
+++ b/frontend/src/components/Stats/index.tsx
@@ -98,20 +98,27 @@ export default function Stats({ user = null }: { user?: null | string }) {
{t("Stats.eventsConfirmed")}
- {user ? (
-
-
- {stats?.trackCount ?? placeholder}
-
- {t("Stats.tracksRecorded")}
-
- ) : (
-
-
- {stats?.userCount ?? placeholder}
-
- {t("Stats.membersJoined")}
-
+
+
+ {stats?.trackCount ?? placeholder}
+
+ {t("Stats.tracksRecorded")}
+
+ {!user && (
+ <>
+
+
+ {stats?.userCount ?? placeholder}
+
+ {t("Stats.membersJoined")}
+
+
+
+ {stats?.deviceCount ?? placeholder}
+
+ {t("Stats.deviceCount")}
+
+ >
)}
diff --git a/frontend/src/translations/de.yaml b/frontend/src/translations/de.yaml
index b0be9b8..b46a7ae 100644
--- a/frontend/src/translations/de.yaml
+++ b/frontend/src/translations/de.yaml
@@ -59,6 +59,7 @@ Stats:
eventsConfirmed: Bestätigte Vorgänge
tracksRecorded: Aufgezeichnete Fahrten
membersJoined: Neue Mitglieder
+ deviceCount: Geräte benutzt
thisMonth: Dieser Monat
thisYear: Dieses Jahr
allTime: Immer
diff --git a/frontend/src/translations/en.yaml b/frontend/src/translations/en.yaml
index d623bc6..34c7408 100644
--- a/frontend/src/translations/en.yaml
+++ b/frontend/src/translations/en.yaml
@@ -64,6 +64,7 @@ Stats:
eventsConfirmed: Events confirmed
tracksRecorded: Tracks recorded
membersJoined: Members joined
+ deviceCount: Devices used
thisMonth: This month
thisYear: This year
allTime: All time
diff --git a/frontend/src/translations/fr.yaml b/frontend/src/translations/fr.yaml
index 6ccfb38..726f2f1 100644
--- a/frontend/src/translations/fr.yaml
+++ b/frontend/src/translations/fr.yaml
@@ -65,6 +65,7 @@ Stats:
eventsConfirmed: Evénements confirmées
tracksRecorded: Traces enregistrées
membersJoined: Membres enregistrés
+ deviceCount: Appareils utilisés
thisMonth: Ce mois
thisYear: Cette annéee
allTime: De tout temps