Get Usage Stats
Headers
Bearer token for authentication
Response
Indicates if the request was successful
Cumulative total requests across all projects
Array of all projects with their usage statistics, sorted by totalRequest in descending order
Implementation Details
Query Logic
- Fetches all projects owned by the authenticated user
- Excludes projects with status
deleted - Results are sorted by
totalRequestin descending order (highest usage first) - Uses lean queries for optimal performance
Selected Fields
The query selects the following fields from the Project model:- name
- projectType
- status
- totalRequest
- plan
- createdAt
- updatedAt
Usage Calculation
- totalRequests: Calculated using reduce to sum the
totalRequestfield across all projects - projectStats: Each project’s
totalRequestfield defaults to 0 if not set or null - Projects with no requests will show
totalRequest: 0
Use Cases
- Monitor which projects are receiving the most traffic
- Identify unused or low-traffic projects
- Track overall platform usage across all deployments
- Compare usage across different project types and plans
- Make data-driven decisions about resource allocation