Add GSC opportunity scorer and wire into analytics/onboarding flows#436
Open
Add GSC opportunity scorer and wire into analytics/onboarding flows#436
Conversation
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.
Motivation
previous_periodpayload from the GSC service so rising/declining trends can be detected.Description
backend/services/analytics/opportunity_scorer.pywith pure functions:high_impression_low_ctr_queries,rising_queries,declining_pages,score_and_rank_opportunities, andcategorize_opportunities, returning the stable opportunity schema (id,query,page_url,reason,score,current_metrics,previous_metrics).GSCAnalyticsHandlerby normalizing current/previous query & page rows, callingcategorize_opportunities(...), and returningopportunitiesalongside existing metrics in handler responses.GSCService.get_search_analyticsto compute a matching previous-date window and optionally fetch previous-periodqueryandpagerows (addedprevious_periodin the analytics payload) to enable window-over-window deltas.backend/api/content_planning/.../data_integration.py) so_get_gsc_analyticsincludesopportunitiesin its output and the onboarding flow reuses the same stable schema.Testing
python -m py_compile backend/services/analytics/opportunity_scorer.py backend/services/analytics/handlers/gsc_handler.py backend/services/gsc_service.py backend/api/content_planning/services/content_strategy/onboarding/data_integration.py; compilation succeeded.from services.analytics.opportunity_scorer import categorize_opportunities) with representative query/page rows to validate categorization and ranking; the function produced a ranked list matching the stable schema.Codex Task