🛠️ Refactor: Endpoints - Strategy Pattern & DRY List Logic#701
🛠️ Refactor: Endpoints - Strategy Pattern & DRY List Logic#701
Conversation
…t Logic - **Strategies:** Introduced `MappingParamProcessor` and `ParamRule` for declarative parameter processing, and `StudyKeyStrategy` (`Keep`/`Pop`) for handling study key extraction. - **Refactoring:** Updated `ParamMixin` to use `StudyKeyStrategy`, replacing `_pop_study_filter` boolean logic. - **Cleanup:** Refactored `UsersParamProcessor` and `RecordsParamProcessor` to use `MappingParamProcessor`. Updated `UsersEndpoint` and `RecordsEndpoint` configuration. - **DRY:** Extracted `_create_paginator_and_parser` in `ListEndpointMixin` to unify setup logic for sync and async list operations. - **Safety:** Maintained backward compatibility for legacy endpoints not explicitly updated. Verified with full test suite passing. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This PR refactors the endpoint layer to improve maintainability and enforce SOLID principles.
Key Changes:
_pop_study_filterboolean flag inParamMixinwith aStudyKeyStrategyclass attribute. This allows for cleaner, polymorphic behavior (Open/Closed Principle). Concrete strategiesPopStudyKeyStrategyandKeepStudyKeyStrategyare implemented.MappingParamProcessorinstrategies.py, allowing endpoints likeUsersandRecordsto define parameter mappings declaratively viaParamRules instead of imperativeprocess_filtersmethods._list_syncand_list_asyncinListEndpointMixininto a shared helper_create_paginator_and_parser. This reduces code duplication and centralizes paginator instantiation logic.UsersEndpointandRecordsEndpointto utilize the new strategies. UpdatedEdcStrictListGetEndpointto usePopStudyKeyStrategyby default.Testing:
pytestsuite (635 tests passed).MappingParamProcessorbehavior with a dedicated test script during development.PR created automatically by Jules for task 4225448565396412763 started by @fderuiter