-
-
Notifications
You must be signed in to change notification settings - Fork 1
[Chore] Refactor shared/api_utils.py to use penguin-libs #72
Copy link
Copy link
Open
Labels
component:apiAPIAPIpriority:lowLow priorityLow prioritystatus:readyReady to work onReady to work ontype:choreMaintenance or toolingMaintenance or tooling
Milestone
Description
User Story
As a maintainer, I want to refactor shared/api_utils.py to leverage penguin-libs utilities so that common API patterns use the shared library instead of local implementations.
Background
shared/api_utils.py provides ~150 lines of generic REST API helpers:
paginate(query, page, per_page)— SQLAlchemy query paginationget_pagination_params()— Extract page/per_page from request argsvalidate_request(schema_class, data)— Marshmallow validationmake_error_response(message, status_code)— Error response formattingmake_success_response(data, message, status_code)— Success response formattingapply_filters(query, model, filters)— Query filteringget_or_404(model, id)— Fetch or abort
Elder already uses penguin_libs.pydantic.flask_integration.validated_request for request validation in 12+ endpoint files, partially overlapping with validate_request().
Acceptance Criteria
- Audit which api_utils functions are still used vs replaced by penguin-libs
- Remove functions superseded by penguin-libs (e.g.,
validate_request→validated_request) - Keep Elder-specific helpers that have no penguin-libs equivalent
- If penguin-libs gains pagination/response utils, migrate to those
- All API endpoints continue working
- Tests pass (unit + integration)
- Linting passes
Notes
- Low effort — mostly removing dead code and consolidating imports
- Some functions may need to stay as Elder-specific thin wrappers
- Consider contributing generic pagination/response utilities back to penguin-libs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
component:apiAPIAPIpriority:lowLow priorityLow prioritystatus:readyReady to work onReady to work ontype:choreMaintenance or toolingMaintenance or tooling