Skip to content

feat: route Insights enrollment APIs through Snowflake - #212

Merged
santhosh-apphelix-2u merged 6 commits into
masterfrom
lp-1002-insights-snowflake-enrollment-apis
Sep 2, 2026
Merged

feat: route Insights enrollment APIs through Snowflake#212
santhosh-apphelix-2u merged 6 commits into
masterfrom
lp-1002-insights-snowflake-enrollment-apis

Conversation

@santhosh-apphelix-2u

Copy link
Copy Markdown

This PR migrates the Insights enrollment API group to support Snowflake-backed reads behind the global Analytics API Waffle flag.

Changes included:

  • Add Snowflake query and mapper support for enrollment endpoints.
  • Add service functions for enrollment, mode, education, gender, and location data.
  • Route the migrated enrollment views through Snowflake when insights_snowflake_enabled is on.
  • Keep Aurora as the default fallback when the flag is off.
  • Preserve the existing API URLs and response shapes.
  • Leave birth year enrollment unchanged because it is outside the current Snowflake migration scope.
  • Add focused tests for query construction, mapping, service wiring, and view routing.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  analytics_data_api/insights_snowflake
  service.py
  analytics_data_api/insights_snowflake/mappers
  enrollment.py
  analytics_data_api/insights_snowflake/queries
  enrollment.py
  analytics_data_api/tests
  test_insights_snowflake.py
  analytics_data_api/v0/tests/views
  test_courses.py
  analytics_data_api/v0/views
  courses.py
Project Total  

This report was generated by python-coverage-comment-action

@santhosh-apphelix-2u
santhosh-apphelix-2u marked this pull request as ready for review September 2, 2026 10:54
Copilot AI lite review requested due to automatic review settings September 2, 2026 10:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It changes the data source routing for multiple production API endpoints, so a final human review is needed to validate behavioral parity and operational readiness beyond the added unit tests.

Pull request overview

This PR migrates the Insights course enrollment API endpoints to support Snowflake-backed reads behind the global insights_snowflake_enabled waffle flag, while preserving existing URLs and response shapes and keeping Aurora as the default when the flag is off.

Changes:

  • Added a reusable SnowflakeCourseEnrollmentMixin to route eligible enrollment views to Snowflake (and set the X-Insights-Data-Source header).
  • Implemented Snowflake enrollment query + mapping + service layers for daily, mode, education, gender, and location enrollment endpoints.
  • Added targeted tests covering query construction, mapper behavior, service wiring, and view routing (including 404 behavior when Snowflake returns no data).
File summaries
File Description
analytics_data_api/v0/views/courses.py Adds Snowflake routing mixin and applies it to migrated enrollment views (keeping birth year unchanged).
analytics_data_api/v0/tests/views/test_courses.py Adds/updates view-level tests to validate Snowflake vs Aurora routing and response headers for enrollment endpoints.
analytics_data_api/tests/test_insights_snowflake.py Adds unit tests for enrollment Snowflake queries, mappers, and service orchestration.
analytics_data_api/insights_snowflake/service.py Adds Snowflake service functions for enrollment-related endpoints.
analytics_data_api/insights_snowflake/queries/enrollment.py Introduces Snowflake SQL query builders for enrollment metrics (latest-date and date-range modes).
analytics_data_api/insights_snowflake/mappers/enrollment.py Introduces enrollment row mappers/pivots to match existing API response shapes (including model-instance mapping for location).
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 2, 2026 11:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It changes production-facing read paths to a new Snowflake SQL/query+mapping stack, which warrants a final human review against real schema/data behavior despite the added tests.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 2, 2026 12:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It introduces new Snowflake-backed query/mapping paths for multiple production endpoints, which warrants final human review for data correctness and rollout safety beyond what can be fully validated here.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 2, 2026 12:34
@santhosh-apphelix-2u
santhosh-apphelix-2u merged commit b1705ae into master Sep 2, 2026
6 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It changes production data-source routing for multiple enrollment endpoints and introduces new Snowflake query/mapping behavior that warrants final human verification.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

analytics_data_api/v0/views/courses.py:313

  • get_snowflake_queryset calls the service function with positional date arguments and raises a bare NotImplementedError, which makes it easier to accidentally pass the wrong values (or get an unhelpful 500) if the service signature changes or a subclass forgets to set the function. Using keyword args here and adding a clearer error message keeps this routing safer and easier to debug.
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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.

3 participants