Skip to content

🛠️ Refactor: Endpoints - Strategy Pattern & DRY List Logic#701

Closed
fderuiter wants to merge 1 commit intomainfrom
refactor-endpoints-strategy-4225448565396412763
Closed

🛠️ Refactor: Endpoints - Strategy Pattern & DRY List Logic#701
fderuiter wants to merge 1 commit intomainfrom
refactor-endpoints-strategy-4225448565396412763

Conversation

@fderuiter
Copy link
Owner

This PR refactors the endpoint layer to improve maintainability and enforce SOLID principles.

Key Changes:

  1. Strategy Pattern for Study Key: Replaced the _pop_study_filter boolean flag in ParamMixin with a StudyKeyStrategy class attribute. This allows for cleaner, polymorphic behavior (Open/Closed Principle). Concrete strategies PopStudyKeyStrategy and KeepStudyKeyStrategy are implemented.
  2. Declarative Parameter Processing: Introduced MappingParamProcessor in strategies.py, allowing endpoints like Users and Records to define parameter mappings declaratively via ParamRules instead of imperative process_filters methods.
  3. DRY List Logic: Extracted common setup code from _list_sync and _list_async in ListEndpointMixin into a shared helper _create_paginator_and_parser. This reduces code duplication and centralizes paginator instantiation logic.
  4. Endpoint Updates: Updated UsersEndpoint and RecordsEndpoint to utilize the new strategies. Updated EdcStrictListGetEndpoint to use PopStudyKeyStrategy by default.

Testing:

  • Ran pytest suite (635 tests passed).
  • Verified MappingParamProcessor behavior with a dedicated test script during development.

PR created automatically by Jules for task 4225448565396412763 started by @fderuiter

…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>
@google-labs-jules
Copy link
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@fderuiter fderuiter closed this Feb 25, 2026
@fderuiter fderuiter deleted the refactor-endpoints-strategy-4225448565396412763 branch February 27, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant