Skip to content

Add bounded query-page opportunities to GSC analytics and normalization#430

Open
AJaySi wants to merge 1 commit intomainfrom
codex/extend-gsc-data-retrieval-and-processing
Open

Add bounded query-page opportunities to GSC analytics and normalization#430
AJaySi wants to merge 1 commit intomainfrom
codex/extend-gsc-data-retrieval-and-processing

Conversation

@AJaySi
Copy link
Owner

@AJaySi AJaySi commented Mar 12, 2026

Motivation

  • Provide query→page opportunity data (query, page, clicks, impressions, ctr, position) to downstream content-planning and agent workflows so they can make refresh-vs-new brief recommendations.
  • Prevent oversized Search Console query+page payloads by bounding the request size and date window to keep API usage predictable and responses manageable.

Description

  • Added constants QUERY_PAGE_OPPORTUNITIES_ROW_LIMIT = 2500 and QUERY_PAGE_OPPORTUNITIES_MAX_WINDOW_DAYS = 90 and use them for the GSC ['query','page'] request to bound rows and date window in backend/services/gsc_service.py.
  • Implemented _get_query_page_opportunity_window to derive a bounded start/end date for the query+page request and included query_page_data.requested_window metadata in the returned analytics payload.
  • Added query_page_opportunities processing in backend/services/analytics/handlers/gsc_handler.py to transform query+page rows into a prioritized list (fields: query, page, clicks, impressions, ctr, position) sorted by opportunity and capped (top 100) for downstream consumption, and included this field in both success and error/partial responses.
  • Updated the autofill normalizer backend/api/content_planning/services/content_strategy/autofill/normalizers/analytics_normalizer.py to pass through query_page_opportunities into the normalized analytics structure.

Testing

  • Compiled the modified modules with python -m compileall backend/services/gsc_service.py backend/services/analytics/handlers/gsc_handler.py backend/api/content_planning/services/content_strategy/autofill/normalizers/analytics_normalizer.py, which completed successfully.
  • No additional automated unit tests were added or run as part of this change.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant