Skip to content

feat: implement real API for kpi_api_analytics.py#223

Open
Nidhi1202 wants to merge 1 commit into
mainfrom
Nidhi1202_160_kpi_api_analytics_v2
Open

feat: implement real API for kpi_api_analytics.py#223
Nidhi1202 wants to merge 1 commit into
mainfrom
Nidhi1202_160_kpi_api_analytics_v2

Conversation

@Nidhi1202

Copy link
Copy Markdown

Closes #160

Summary

Implements the KPI Analytics Lambda with real PostgreSQL queries against the Virginia RDS database.

What's implemented

  • Request Status Distribution — counts requests joined to the request_status lookup, filtered to the dashboard statuses (CREATED, IN_PROGRESS, RESOLVED)
  • Total Requests — count across all statuses
  • Average Resolution Time by Category — AVG(serviced_date - submission_date) in hours, joined to help_categories for the category name, for RESOLVED requests only
  • SLA metadata — always returned, per the dashboard spec

Notes

  • The request_status lookup table contains RESOLVED but not COMPLETED, so the resolution-time query filters on RESOLVED only.
  • The issue text states the formula as submission_date - serviced_date, which would produce negative values. Implemented as serviced_date - submission_date.
  • Added an optional environment-variable path for the DB connection so the Lambda can be run locally without AWS/SSM access. Production still reads credentials from SSM.

Testing

Returns the safe default response when credentials are not configured. Verified locally against a PostgreSQL instance built from the schema in Saayam_Table.column.names_data.xlsx — statusCode 200, all four keys present, empty DB returns [] and 0 without crashing, and the connection closes in the finally block. Full integration testing requires Virginia RDS credentials.

@Nidhi1202
Nidhi1202 requested review from sana-desai and saquibb8 July 14, 2026 03:53
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.

Implement real API for KPI_API_Analytics.py— complete, test & deploy

1 participant