fix: eliminate redundant DB queries in get_learning_paths#119
Draft
cursor[bot] wants to merge 1 commit intofeat/learning-path-exemplarsfrom
Draft
fix: eliminate redundant DB queries in get_learning_paths#119cursor[bot] wants to merge 1 commit intofeat/learning-path-exemplarsfrom
cursor[bot] wants to merge 1 commit intofeat/learning-path-exemplarsfrom
Conversation
…pre-loaded data Extract pattern-building and exemplar-derivation logic from get_pattern_sharing into a shared _build_patterns_and_exemplars helper. get_learning_paths now: - Expands its existing facets query to include extra columns needed for pattern building (outcome, agent_helpfulness, brief_summary) - Builds session_map, session_facets, session_tools, session_tool_count from data already being queried - Runs only 2 additional queries (workflow profiles, model costs) - Calls _build_patterns_and_exemplars directly instead of get_pattern_sharing This eliminates 4 redundant DB queries (sessions, engineer names, facets, tool usages) that were previously re-executed by get_pattern_sharing.
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.
Problem
get_learning_pathscalledget_pattern_sharingas a black box but only usedexemplar_sessionsfrom the result. This duplicated four DB queries already performed byget_learning_paths(sessions, engineer names, facets, tool usages) and additionally computed patterns, bright spots, workflow profiles, and model costs — all discarded except the exemplar list. This effectively doubled the database load for the/learning-pathsendpoint.Solution
Extracted the pattern-building and exemplar-derivation logic from
get_pattern_sharinginto a shared_build_patterns_and_exemplarshelper function. Bothget_pattern_sharingandget_learning_pathsnow call this helper with pre-loaded data.Changes to
get_learning_paths:outcome,agent_helpfulness,brief_summary)session_map,session_facets,session_tools,session_tool_countfrom data already being queried_build_patterns_and_exemplarsdirectly instead ofget_pattern_sharingThis eliminates 4 redundant DB queries (sessions, engineer names, facets, tool usages) and avoids all the discarded intermediate computation (pattern clustering, bright spots).
Testing
All 21 tests in
tests/test_growth.pypass (learning paths, pattern sharing, and onboarding acceleration). Ruff lint and format checks pass.