feat: add geolocation fields to session and implement geo stats endpoint

- Added country, city, countryCode, latitude, and longitude fields to the Session model.
- Updated geoip service to fetch and store geolocation data based on user IP.
- Created a new admin endpoint to retrieve geolocation statistics, including user counts by country and city.
- Enhanced admin page to display geolocation statistics with expandable city details.
- Introduced caching for geolocation data to optimize performance.
This commit is contained in:
Jose Selesan
2026-06-10 10:18:31 -03:00
parent 00f0cf511f
commit dc8a10a612
15 changed files with 389 additions and 30 deletions

View File

@@ -4,6 +4,7 @@ import { requireSuperAdmin } from '@/middlewares/require-super-admin.middleware'
import { blockUserHandler } from '@/modules/admin/handlers/block-user.handler';
import { createPlanHandler } from '@/modules/admin/handlers/create-plan.handler';
import { deletePlanHandler } from '@/modules/admin/handlers/delete-plan.handler';
import { getGeoStatsHandler } from '@/modules/admin/handlers/get-geo-stats.handler';
import { getUserSessionsHandler } from '@/modules/admin/handlers/get-user-sessions.handler';
import { listComplexesHandler } from '@/modules/admin/handlers/list-complexes.handler';
import { listPlansAdminHandler } from '@/modules/admin/handlers/list-plans-admin.handler';
@@ -40,6 +41,8 @@ adminRoutes.delete(
deletePlanHandler
);
adminRoutes.get('/geo-stats', getGeoStatsHandler);
adminRoutes.get('/users', listUsersHandler);
adminRoutes.post(
'/users/:id/block',