Skip to content

feat: route Insights video APIs through Snowflake - #214

Merged
santhosh-apphelix-2u merged 4 commits into
masterfrom
lp-1002-insights-snowflake-engagement-videos
Sep 3, 2026
Merged

feat: route Insights video APIs through Snowflake#214
santhosh-apphelix-2u merged 4 commits into
masterfrom
lp-1002-insights-snowflake-engagement-videos

Conversation

@santhosh-apphelix-2u

Copy link
Copy Markdown

Description

Migrates the Insights video engagement APIs to support Snowflake reads behind the global insights_snowflake_enabled Waffle flag.

This covers:

  • GET /api/v1/courses/{course_id}/videos/
  • GET /api/v1/videos/{video_id}/timeline/

Aurora remains the default path when the flag is off.

Changes

  • Added Snowflake query helpers for VIDEO and VIDEO_TIMELINE.
  • Added video mappers to keep the existing API response shape.
  • Added service functions for course videos and video timeline data.
  • Updated the existing video views to route to Snowflake only when the global flag is enabled.
  • Added focused tests for query construction, mapping, service orchestration, source headers, and empty-result behavior.

@github-actions

github-actions Bot commented Sep 3, 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
  videos.py
  analytics_data_api/insights_snowflake/queries
  videos.py
  analytics_data_api/tests
  test_insights_snowflake.py
  analytics_data_api/v0/tests/views
  test_courses.py
  test_videos.py
  analytics_data_api/v0/views
  courses.py
  videos.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 3, 2026 10:16
Copilot AI lite review requested due to automatic review settings September 3, 2026 10:16
@santhosh-apphelix-2u
santhosh-apphelix-2u merged commit 778a238 into master Sep 3, 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.

🟡 Changes recommended

There are correctness issues that can cause failures in Snowflake row mapping (NULL integer handling) and in test cleanup logic (thread-local DB hint fallback can point to a non-existent DB alias).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Migrates the Insights video engagement endpoints to optionally read from Snowflake (behind the global insights_snowflake_enabled Waffle flag) while preserving existing response shapes and adding an X-Insights-Data-Source response header indicating Aurora vs Snowflake.

Changes:

  • Added Snowflake query + mapping + service layers for course videos and video timeline endpoints.
  • Updated existing course/videos and video/timeline views to route through Snowflake only when the global flag is enabled (otherwise defaulting to Aurora).
  • Added unit tests covering query construction, mapping, service orchestration, data-source headers, and empty-result 404 behavior.
File summaries
File Description
analytics_data_api/v0/views/videos.py Routes videos/{video_id}/timeline/ through Snowflake when enabled and sets data-source response header.
analytics_data_api/v0/views/courses.py Routes courses/{course_id}/videos/ through Snowflake when enabled and sets data-source response header.
analytics_data_api/v0/tests/views/test_videos.py Adds view-level tests for Snowflake/Aurora routing, headers, and empty-result 404 behavior.
analytics_data_api/v0/tests/views/test_courses.py Adds view-level tests for Snowflake/Aurora routing, headers, and empty-result 404 behavior.
analytics_data_api/tests/test_insights_snowflake.py Adds tests for Snowflake video query SQL, mappers, and service orchestration.
analytics_data_api/insights_snowflake/service.py Adds service functions to orchestrate video queries and mapping.
analytics_data_api/insights_snowflake/queries/videos.py Introduces Snowflake SQL query helpers for course videos and video timeline data.
analytics_data_api/insights_snowflake/mappers/videos.py Introduces Snowflake row-to-API-shape mappers for video and timeline data.
Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 3
  • Review effort level: Lite

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

Comment on lines +38 to +41
value = _row_value(row, name)
if name in INTEGER_FIELDS:
return int(value)
return value
Comment on lines +1018 to +1020
def tearDown(self):
thread_data.analyticsapi_database = getattr(settings, 'ANALYTICS_DATABASE', 'analytics')
super().tearDown()
Comment on lines +16 to +18
def tearDown(self):
thread_data.analyticsapi_database = getattr(settings, 'ANALYTICS_DATABASE', 'analytics')
super().tearDown()
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