Skip to content

feat: add upload analytics API with key metrics and usage insights#102

Open
Krushna-Pisal wants to merge 4 commits into
indictechcom:masterfrom
Krushna-Pisal:upload_progress_api
Open

feat: add upload analytics API with key metrics and usage insights#102
Krushna-Pisal wants to merge 4 commits into
indictechcom:masterfrom
Krushna-Pisal:upload_progress_api

Conversation

@Krushna-Pisal
Copy link
Copy Markdown

This PR adds a new analytics endpoint to provide useful insights into the upload system. It helps in understanding usage patterns, tracking performance, and identifying failures more easily.


###What is Added

A new endpoint:

GET /api/upload/stats

This endpoint returns key metrics such as:

  • Total uploads
  • Successful uploads
  • Failed uploads
  • Success rate (%)
  • Average upload time (in seconds)
  • Uploads in the last 24 hours

###Additional Insights

To make the API more useful for monitoring and future UI integration, the following are also included:

  • Status distribution (success / failed / processing)
  • File type distribution (e.g., jpg, pdf, png)
  • Daily upload trend (last 7 days)

###Implementation Notes

  • Uses SQLAlchemy aggregation queries for better performance
  • Handles edge cases like empty datasets and null values
  • Follows a modular structure with a separate service layer
  • Keeps response format consistent with existing APIs

Sample Response

{
  "status": "success",
  "data": {
    "total_uploads": 250,
    "successful_uploads": 210,
    "failed_uploads": 40,
    "success_rate": 84.0,
    "average_upload_time": 3.1,
    "uploads_last_24h": 22,
    "status_distribution": {
      "success": 210,
      "failed": 40,
      "processing": 5
    },
    "file_type_distribution": {
      "jpg": 80,
      "pdf": 60
    },
    "daily_upload_trend": [
      {"date": "2026-04-20", "count": 10},
      {"date": "2026-04-21", "count": 15}
    ]
  }
}

🚀 Why This Matters

This adds basic observability to the upload system and can be useful for:

  • Monitoring system health
  • Debugging upload failures
  • Supporting future dashboard or admin UI

Future Improvements

  • Add filters (date range, file type, user)
  • Integrate with frontend dashboard
  • Export analytics data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant