Unify GSC analytics response contract and status-driven consumers#429
Open
Unify GSC analytics response contract and status-driven consumers#429
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
get_search_analyticsalways returns a single, predictable shape so downstream code can rely on keys rather than presence checks.statusmarker and empty collections.status+ guaranteed keys instead of brittle key-existence logic.Description
GSCService.get_search_analytics:_base_payload(status, error)and_normalize_payload(payload)that guarantee the unified contract with keys:overall_metrics.rows,query_data.rows,page_data.rows,query_page_data.rows,verification_data.rows,date_range(start/end),site_url,startDate/endDate/siteUrlaliases,status, and optionalerror/warning.get_search_analyticsto return the canonical payload with appropriatestatusvalues (examples:not_connected,auth_failed,no_data,verification_failed,api_error,partial_success,success,error) and empty arrays instead of ad-hoc dict shapes.date_range,site_url, andstatusand ensure cached responses are converted via_normalize_payloadbefore being returned.statusand guaranteed keys:backend/services/analytics/handlers/gsc_handler.pynow derives metrics fromoverall_metrics/query_dataand computes connection status fromstatus;backend/services/scheduler/executors/gsc_insights_executor.pychecksstatusrather than presence of'error'; onboarding normalizernormalize_gsc_analyticsgates processing based onstatus.Testing
python -m compileall backend/services/gsc_service.py backend/services/analytics/handlers/gsc_handler.py backend/services/scheduler/executors/gsc_insights_executor.py backend/api/content_planning/services/content_strategy/autofill/normalizers/analytics_normalizer.pyand all modified modules compiled without syntax errors.Codex Task