Skip to content

feat: add Insights Snowflake foundation and routing - #203

Merged
santhosh-apphelix-2u merged 5 commits into
masterfrom
lp-1000-1001-insights-snowflake-foundation-routing
Aug 7, 2026
Merged

feat: add Insights Snowflake foundation and routing#203
santhosh-apphelix-2u merged 5 commits into
masterfrom
lp-1000-1001-insights-snowflake-foundation-routing

Conversation

@santhosh-apphelix-2u

Copy link
Copy Markdown

Adds the Snowflake API foundation and safe endpoint-level routing for Insights.

This covers the planned work for LP-1000 and LP-1001:

  • LP-1000: build the Snowflake API foundation inside edx-analytics-data-api
  • LP-1001: add safe endpoint-level routing between Aurora and Snowflake

The existing dashboard API URL remains unchanged. Aurora remains the default path unless the endpoint Waffle flag is enabled.

Changes

  • Added analytics_data_api.insights_snowflake package.
  • Added Snowflake client wrapper, service layer, query module, mapper module, and toggle helper.
  • Added endpoint-level Waffle flag: insights_snowflake_course_activity.
  • Updated CourseActivityWeeklyView to use Snowflake only when the flag is enabled.
  • Kept the existing Aurora path unchanged when the flag is disabled.
  • Added focused tests for helper logic, mapping, service orchestration, and flag-based routing.

…23 pycodestyle error

Co-authored-by: santhosh-apphelix-2u <211942388+santhosh-apphelix-2u@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  analytics_data_api
  snowflake_client.py
  analytics_data_api/insights_snowflake
  client.py
  service.py
  toggles.py
  analytics_data_api/insights_snowflake/mappers
  activity.py
  analytics_data_api/insights_snowflake/queries
  activity.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 August 7, 2026 04:24
Copilot AI lite review requested due to automatic review settings August 7, 2026 04: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.

Pull request overview

Adds an insights_snowflake foundation package and wires CourseActivityWeeklyView to route to Snowflake behind a Waffle flag, while preserving the existing Aurora-backed behavior by default.

Changes:

  • Introduces analytics_data_api.insights_snowflake (client/query/mapper/service + Waffle toggle) for endpoint-safe Snowflake reads.
  • Updates CourseActivityWeeklyView to conditionally source data from Snowflake and emit an X-Insights-Data-Source response header.
  • Adds unit tests covering Snowflake helpers and flag-based routing behavior in the course activity endpoint.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
analytics_data_api/v0/views/courses.py Adds flag-gated Snowflake routing for course activity and emits a data-source response header.
analytics_data_api/v0/tests/views/test_courses.py Adds tests for Aurora vs Snowflake routing and cleans up thread-local DB routing state.
analytics_data_api/tests/test_insights_snowflake.py New tests for Snowflake client/query/mapper/service/toggle helpers with mocked execution.
analytics_data_api/snowflake_client.py Updates module docstring to reflect endpoint usage via the new package.
analytics_data_api/insights_snowflake/init.py Declares the new Insights Snowflake package.
analytics_data_api/insights_snowflake/client.py Adds endpoint-safe Snowflake query helper enforcing SELECT-only and returning dict rows.
analytics_data_api/insights_snowflake/service.py Adds service wrapper orchestrating query + mapping for course activity.
analytics_data_api/insights_snowflake/toggles.py Adds Waffle flag wrapper for endpoint-level Snowflake enablement.
analytics_data_api/insights_snowflake/queries/init.py Declares query helpers package.
analytics_data_api/insights_snowflake/queries/activity.py Adds Snowflake SQL for course activity weekly (latest week or date-range).
analytics_data_api/insights_snowflake/mappers/init.py Declares mappers package.
analytics_data_api/insights_snowflake/mappers/activity.py Maps/pivots Snowflake rows into the existing API response shape.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +151 to +155
if is_course_activity_snowflake_enabled(self.request):
self.insights_data_source = self.data_source_snowflake
data = get_course_activity_weekly(self.course_id, self.start_date, self.end_date)
if data:
return data
Comment on lines +37 to +40
finally:
if cursor is not None:
cursor.close()
connection.close()
@santhosh-apphelix-2u
santhosh-apphelix-2u merged commit b8cbffe into master Aug 7, 2026
6 checks passed
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.

4 participants