Skip to content

#181: Add date filter support to KPI analytics API#220

Open
sanobarasna wants to merge 1 commit into
devfrom
sanobarasna_181_kpi_date_filters_v2
Open

#181: Add date filter support to KPI analytics API#220
sanobarasna wants to merge 1 commit into
devfrom
sanobarasna_181_kpi_date_filters_v2

Conversation

@sanobarasna

@sanobarasna sanobarasna commented Jul 13, 2026

Copy link
Copy Markdown

Summary

Adds date filter support (7D, 30D, 1Y, All, Custom) to the existing
KPI analytics Lambda (kpi_api_analytics.py).

Changes

  • New build_date_filter(time_range, start_date=None, end_date=None)
    helper, returns a parameterized SQL condition + params
  • Updated all three fetch functions to accept and apply the date filter
  • Updated lambda_handler() to read time_range, start_date,
    end_date from the event payload (defaults to "All")
  • Added a local-testing DB connection path (LOCAL_DB_TEST=1 env var)

Schema verification

Confirmed against Saayam_Table_column_names_data.xlsx for
virginia_dev_saayam_rdbms:

  • request.submission_date, request.serviced_date
  • request.req_status_id, request.req_cat_id
  • request_status.req_status_id, req_status
  • help_categories.cat_id, cat_name

Testing

Ran locally with LOCAL_DB_TEST=1 against Virginia dev DB, all 6
required payloads (7D, 30D, 1Y, All, Custom), all return
statusCode 200 with the expected response shape. SLA block and
error-handling pattern unchanged.

Notes for reviewers

  • No frontend/UI changes made, per scope
  • No new API file created
  • Unrecognized time_range values fall back to "All" rather than
    erroring, flagging for visibility since it's not explicitly
    specified in the ticket

Closes 181

- Add build_date_filter() helper supporting 7D/30D/1Y/All/Custom
- Update fetch_request_status_distribution, fetch_total_requests,
  fetch_average_resolution_time_by_category to accept time_range,
  start_date, end_date
- Update lambda_handler to read filter params from event payload
- Add local DB connection path (LOCAL_DB_TEST env var) for local testing
- Verified against Virginia dev schema (submission_date, serviced_date,
  req_status_id, req_cat_id confirmed)
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