You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have duplicate filter enum definitions across the entity_api and web layers. Each filter is defined twice with manual mapping in controllers. This should be unified using a trait-based pattern.
Current State
Three filter types are duplicated:
Filter
entity_api
web/params
Controller Mapping
RoleFilter
coaching_relationship.rs
coaching_relationship.rs:8
✅ Fixed via RoleFilterable trait
Scope
action.rs:239
action.rs:14
Manual match in action_controller.rs:64-67
AssigneeFilter
action.rs:227
action.rs:27
Manual match in action_controller.rs:70-74
Proposed Solution
Create a generic Filterable trait in entity_api/src/filter.rs:
// entity_api/src/filter.rspubtraitFilterable{// Design TBD - could be:// fn to_condition(&self) -> Condition;// or a simpler boolean predicate pattern}
Benefits
Single source of truth for each filter (web layer only)
No manual mapping in controllers
Clear pattern for future filters
Preserved dependency graph: web → domain → entity_api
Implementation Steps
Create entity_api/src/filter.rs with generic Filterable trait
Refactor RoleFilterable to use the new pattern (or keep as-is if different)
Create traits for Scope and AssigneeFilter
Remove duplicate enums from entity_api/src/action.rs
Update FindByUserParams to accept impl Trait instead of concrete types
Simplify action_controller.rs to pass web types directly
Update domain re-exports
Context
This was identified during PR #215 code review. The RoleFilter was fixed as a proof of concept, demonstrating the pattern works. The remaining filters should follow the same approach.
Summary
We have duplicate filter enum definitions across the
entity_apiandweblayers. Each filter is defined twice with manual mapping in controllers. This should be unified using a trait-based pattern.Current State
Three filter types are duplicated:
RoleFiltercoaching_relationship.rscoaching_relationship.rs:8RoleFilterabletraitScopeaction.rs:239action.rs:14action_controller.rs:64-67AssigneeFilteraction.rs:227action.rs:27action_controller.rs:70-74Proposed Solution
Create a generic
Filterabletrait inentity_api/src/filter.rs:Benefits
web → domain → entity_apiImplementation Steps
entity_api/src/filter.rswith genericFilterabletraitRoleFilterableto use the new pattern (or keep as-is if different)ScopeandAssigneeFilterentity_api/src/action.rsFindByUserParamsto acceptimpl Traitinstead of concrete typesaction_controller.rsto pass web types directlyContext
This was identified during PR #215 code review. The
RoleFilterwas fixed as a proof of concept, demonstrating the pattern works. The remaining filters should follow the same approach.References
cc16258: refactor: Unify RoleFilter using trait-based pattern