Get Dashboard Statistics
Endpoint
Authentication
Requires JWT authentication token withmonitor or admin role.
Required Roles: monitor, admin
Response Fields
Total number of active members (users with
socio = 1)Total number of non-members (users with
socio = 2)Total number of activities registered in the system
Total number of projects (all statuses)
Number of projects with status “Activo”
Number of projects with status “Pendiente”
Total number of workers (users with category “Trabajador”)
Caching
This endpoint implements intelligent caching to optimize performance:- Cache Key:
dashboard_stats - TTL (Time To Live): 5 minutes (300,000 milliseconds)
- Cache Behavior:
- First request fetches data from the database and stores it in cache
- Subsequent requests within 5 minutes return cached data
- After 5 minutes, cache expires and next request refreshes the data
- Reduces database load for frequently accessed statistics
- Improves response time for dashboard loads
- Ensures data is reasonably fresh (updated every 5 minutes)
Database Queries
The endpoint executes a single optimized aggregated query:Security
- Protected Endpoint: Only authenticated users can access
- Role-Based Access: Requires
monitororadminrole - JWT Guards: Implements both
JwtAuthGuardandRolesGuard - Data Privacy: Statistics are aggregated counts with no personal information exposed
Use Cases
- Dashboard Loading: Display key metrics on the admin dashboard
- Reporting: Generate quick summary reports for board meetings
- Monitoring: Track growth trends (members, projects, activities)
- Health Checks: Verify system activity and engagement levels
Performance Notes
- Optimized Query: Single aggregated query reduces database round trips
- Cache Strategy: 5-minute cache significantly reduces database load
- Scalability: Suitable for associations with thousands of members
- Response Time: Typically under 50ms (cached) or under 200ms (uncached)
