feat: add Insights Snowflake foundation and routing - #203
Merged
santhosh-apphelix-2u merged 5 commits intoAug 7, 2026
Merged
Conversation
…23 pycodestyle error Co-authored-by: santhosh-apphelix-2u <211942388+santhosh-apphelix-2u@users.noreply.github.com>
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
alenkadev
approved these changes
Aug 7, 2026
There was a problem hiding this comment.
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
CourseActivityWeeklyViewto conditionally source data from Snowflake and emit anX-Insights-Data-Sourceresponse 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the Snowflake API foundation and safe endpoint-level routing for Insights.
This covers the planned work for LP-1000 and LP-1001:
edx-analytics-data-apiThe existing dashboard API URL remains unchanged. Aurora remains the default path unless the endpoint Waffle flag is enabled.
Changes
analytics_data_api.insights_snowflakepackage.insights_snowflake_course_activity.CourseActivityWeeklyViewto use Snowflake only when the flag is enabled.